#include #define x first #define y second using namespace std; using ll=long long; using pii=pair; using vi=vector; using vl=vector; #define pb push_back #define all(a) begin(a),end(a) const int N=300010,MOD=1e9+7; const char en='\n'; const ll LLINF=1ll<<60; int n,dif[N]; string a,b; vector>> ord; set s[300][300]; void dfs(char c) { for (auto u: {'-','M','C'}) while (s[c][u].size()) { int x=*s[c][u].begin(); s[c][u].erase(x); dfs(u); ord.pb({x,{c,u}}); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>a>>b; for (int i=0;i0 && s['C']['M'].size()) { int u=*s['C']['M'].begin(); s['C']['M'].erase(u); --dif['M']; s['C']['-'].insert(u); ++dif['-']; } while (dif['C']>0 && s['M']['C'].size()) { int u=*s['M']['C'].begin(); s['M']['C'].erase(u); --dif['C']; s['M']['-'].insert(u); ++dif['-']; } while (dif['M']>0 && s['-']['M'].size()) { int u=*s['-']['M'].begin(); s['-']['M'].erase(u); --dif['M']; } while (dif['C']>0 && s['-']['C'].size()) { int u=*s['-']['C'].begin(); s['-']['C'].erase(u); --dif['C']; } dfs('-'); reverse(all(ord)); vector> v; for (auto x: ord) { v.pb({"DRIVE",x.x+1}); if (x.y.x!='-') v.pb({"DROPOFF",-1}); if (x.y.y!='-') v.pb({"PICKUP",-1}); } cout<