#include "bits/stdc++.h" using namespace std; using LL = long long; using ll = long long; #define all(x) begin(x),end(x) const int E = 2, C = 0, M = 1; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector v[3][3]; // need, have string s, t; cin >> s >> t; for(int i = 0; i < n; ++i){ int x = E; if(s[i] == 'C') x = C; if(s[i] == 'M') x = M; int y = E; if(t[i] == 'C') y = C; if(t[i] == 'M') y = M; v[x][y].push_back(i+1); } // 0M source of math, 0C source of cs // if any 0M start from him, do as many MC-CM as possible, then end at (M/C)0 or any MM CC 00 // if any 0C start from him, do as many CM-MC as possible, then end at (M/C)0 or any MM CC 00 // if any 0M or 0C left, dump them into M0 and C0 and even CM/MC (can there still be any?) auto cnt = [&](int t, int tt){ return v[t][tt].size(); }; auto need = [&](int t){ return v[t][E].size() + v[t][1^t].size(); }; int anslen = 0; string ans; auto go = [&](int t, int tt){ int i = v[t][tt].back(); v[t][tt].pop_back(); ans += "DRIVE "; ans += to_string(i); ans += "\n"; ++anslen; }; auto pick = [&](){ ans += "PICKUP\n"; ++anslen; }; auto drop = [&](){ ans += "DROPOFF\n"; ++anslen; }; while(need(M) + need(C)){ assert(cnt(E, M) + cnt(E, C)); int curr = E; if(need(M) && cnt(E, M)){ // start with a M go(E, M); pick(); curr = M; } else if(need(C) && cnt(E, C)){ // start with a C go(E, C); pick(); curr = C; } assert(curr != E); while(curr != E && need(curr)){ if(cnt(curr, 1^curr)){ // swap go(curr, 1^curr); drop(); // devo pickare? if(need(1^curr)){ curr ^= 1; pick(); } else curr = E; } else { // dst go(curr, E); drop(); curr = E; } } if(curr != E){ drop(); curr = E; } } cout << anslen << endl; cout << ans << endl; }