#include using namespace std; using ll = long long; #define sz(x) (int)(x).size() struct state { string want, have; int at=-1; char pass='-'; vector vis; vector> ops; state(string a, string b) { want=a; have=b; vis.assign(a.size(), 0); } int unsat() { for(int i=0;i>n; string a,b; cin>>a>>b; for(char elso:{'C', 'M'}) { state st(a,b); if(st.find('-', elso)!=-1) { int where=st.find('-', elso); st.drive(where); st.pickup(); st.debug(); while(!st.valid()) { st.debug(); if(st.pass!='-') { int akt=st.find(st.pass, other(st.pass)); if(akt!=-1) { st.drive(akt); st.ops.emplace_back("DROPOFF", -1); st.ops.emplace_back("PICKUP", -1); swap(st.have[akt], st.pass); }else { akt=st.find(st.pass, '-'); if(akt==-1) { if(!st.ops.empty() && st.ops.back().first=="PICKUP") { st.ops.pop_back(); }else { st.ops.emplace_back("DROPOFF", -1); } st.pass='-'; continue ; } st.drive(akt); st.dropoff(); } }else { assert(st.unsat()!=-1); char kellChar=st.want[st.unsat()]; // cerr<