#include using namespace std; int convert(char c) { if (c == '-') return 0; else if (c == 'C') return 1; else return 2; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; string need, have; cin >> need >> have; need = " " + need, have = " " + have; vector v[3][3]; // need, have for (int i = 1; i <= n; ++i) { v[convert(need[i])][convert(have[i])].push_back(i); } vector solution; while (!v[0][1].empty() || !v[0][2].empty()) { int n = 0, h = !v[0][1].empty() ? 1 : 2; // cout << "START AT " << n << ' ' << h << endl; while (true) { int id = v[n][h].back(); v[n][h].pop_back(); solution.push_back("DRIVE " + to_string(id)); if (n) solution.push_back("DROPOFF"); // cout << " at " << n << ' ' << h << endl; // going to another one? bool cont = false; int n2 = h, h2 = 0; if (h) { if (!v[h][3-h].empty()) h2 = 3-h, cont = true; else if (!v[h][0].empty()) h2 = 0, cont = true; } if (!cont) break; solution.push_back("PICKUP"); n = n2, h = h2; } } for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if (i && i != j) assert(v[i][j].empty()); } } cout << solution.size() << '\n'; for (string &s : solution) cout << s << '\n'; return 0; }