#include #define pii pair using namespace std; string a; string b; vector x_[2]; vector _x[2]; // C = 0, M = 1 vector xy[2]; struct ura { string a; int x; }; vectorans; void solve() { int n; cin >> n; cin >> a; a = '#' + a; cin >> b; b = '#' + b; for(int i = 1; i <= n; ++i) { if(a[i] == b[i]) continue; if(a[i] == '-') { if(b[i] == 'C') _x[0].push_back(i); else _x[1].push_back(i); } else if (b[i] == '-') { if(a[i] == 'C') x_[0].push_back(i); else x_[1].push_back(i); } else { if(a[i] == 'C') xy[0].push_back(i); else xy[1].push_back(i); } } int x = 0; while(!_x[x].empty()) { int pz = _x[x].back(); _x[x].pop_back(); int ceam = x; if(!xy[ceam].empty() || !x_[ceam].empty()) { ans.push_back({"DRIVE", pz}); ans.push_back({"PICKUP", 0}); } while(1) { if(!xy[ceam].empty()) { int npz = xy[ceam].back(); xy[ceam].pop_back(); ans.push_back({"DRIVE", npz}); ans.push_back({"DROPOFF", 0}); ceam = 1-ceam; if(!xy[ceam].empty() || !x_[ceam].empty()) ans.push_back({"PICKUP", 0}); } else break; } if(x_[ceam].empty()) { continue; } assert(!x_[ceam].empty()); pz = x_[ceam].back(); ans.push_back({"DRIVE", pz}); ans.push_back({"DROPOFF", 0}); } x = 1; while(!_x[x].empty()) { int pz = _x[x].back(); _x[x].pop_back(); int ceam = x; if(!xy[ceam].empty() || !x_[ceam].empty()) { ans.push_back({"DRIVE", pz}); ans.push_back({"PICKUP", 0}); } while(1) { if(!xy[ceam].empty()) { int npz = xy[ceam].back(); xy[ceam].pop_back(); ans.push_back({"DRIVE", npz}); ans.push_back({"DROPOFF", 0}); ceam = 1-ceam; if(!xy[ceam].empty() || !x_[ceam].empty()) ans.push_back({"PICKUP", 0}); } else break; } if(x_[ceam].empty()) { continue; } assert(!x_[ceam].empty()); pz = x_[ceam].back(); ans.push_back({"DRIVE", pz}); ans.push_back({"DROPOFF", 0}); } cout << ans.size() << '\n'; for(auto i:ans) { cout << i.a << ' '; if(i.x != 0) cout << i.x; cout<<'\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("test.in", "r", stdin); freopen("test.out", "w", stdout); #else #endif int T = 1; //cin >> T; while(T--) { solve(); } return 0; }