#include using namespace std; using ll = long long int; using ld = long double; #define N 2010 #define pii pair #define mk make_pair int n; char building[N], prof[N]; vector acc[2], confli[2], have[2]; // 0 for cs 1 for math vector res; int pop_back_get(vector& vec) { int res = *vec.rbegin(); vec.pop_back(); return res; } bool need_sub(int sub) { return acc[0].size() + confli[0].size() > 0; } int need() { if(confli[0].size() > confli[1].size()) return 0; if(confli[1].size() > confli[0].size()) return 0; if(confli[0].size() > 0) return 0; if(confli[1].size() > 0) return 1; if(need_sub(0)) return 0; else if(need_sub(1)) return 1; else return -1; } int get(int sub) { if(have[sub].empty()) return -1; return pop_back_get(have[sub]); } int give(int sub) { if(confli[sub].empty()) { if(acc[sub].empty()) return -1; return pop_back_get(acc[sub]); } else { return pop_back_get(confli[sub]); } } int main(void) { ios_base::sync_with_stdio(false); cin >> n >> building >> prof; for(int i=0;i