#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } bool solve(int x, int y){ static bool seen[1000][1000]; static bool win[1000][1000]; if(seen[x][y]) return win[x][y]; if(x == y) return true; if(x == 0 || y == 0) return true; bool ans = false; for(int xx = 0; xx < x && !ans; xx++){ if(!solve(xx, y)) { ans = true; } } for(int yy = 0; yy < y && !ans; yy++){ if(!solve(x, yy)) { ans = true; } } seen[x][y] = true; win[x][y] = ans; return ans; } void test(){ for(int x = 1; x <= 100; x++){ for(int y = 1; y <= 100; y++){ if(!solve(x, y)) cout << "lose:" << x << ' ' << y << endl; } } cout << "Done" << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; vector v(2); for(int i = 0; i < 2; i++) cin >> v[i]; auto do_next = [&](){ if(v[0] == v[1]){ cout << "B" << endl; return; } if(v[0] == 0){ cout << "A " << 2 << ' ' << v[1] << endl; return; } if(v[1] == 0){ cout << "A " << 1 << ' ' << v[0] << endl; return; } int small_idx = v[0] < v[1] ? 0 : 1; int large_idx = small_idx^1; if(v[small_idx]%2 == 1){ cout << "A " << large_idx+1 << ' ' << v[large_idx]-v[small_idx]-1 << endl; v[large_idx] = v[small_idx]+1; }else{ cout << "A " << large_idx+1 << ' ' << v[large_idx]-v[small_idx]+1 << endl; v[large_idx] = v[small_idx]-1; } }; auto do_opponent = [&](){ string s; cin >> s; if(s == "A"){ int i, x; cin >> i >> x; i--; v[i] -= x; }else if(s == "B"){ v[0] = 0; v[1] = 0; }else{ exit(0); } }; bool first = true; if(abs(v[0]-v[1]) == 1){ int mn = min(v[0], v[1]); if(mn%2 == 1){ first = false; } } if(first) cout << "First" << endl; else{ cout << "Second" << endl; do_opponent(); } while(true){ do_next(); do_opponent(); // cout << "v:"; print_vector(v); } }