#include #define all(a) a.begin(),a.end() #define len(a) (int)(a.size()) #define fir first #define sec second #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef pair pii; typedef long long ll; typedef long double ld; template bool umin(T &a, T b) { if (b < a) { a = b; return 1; } return 0; } template bool umax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } #ifdef KIVI #define DEBUG for (int _____DEBUG=1;_____DEBUG;_____DEBUG=0) #define LOG(...) prnt(#__VA_ARGS__" ::",__VA_ARGS__)< auto &prnt(Ts ...ts) { return ((cerr << ts << " "), ...); } #else #define DEBUG while (false) #define LOG(...) #endif const int max_n = -1, inf = 1000111222; vector ids[3][3]; vector> ans; void dfs(int have,int want) { LOG("dfs",have,want); ans.back().pb(ids[have][want].back()); ids[have][want].pop_back(); if(have == 0) return; for (int had=0;had<3;had++){ if (!ids[had][have].empty()){ dfs(had,have); return; } } LOG("left free",have); } int main() { // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; string want,init; cin>>want>>init; for (int i=0;i