#include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i, n, N) for(ll i=(n);i<(N);i++) #define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--) #define CK(n, a, b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(), (v).end() #define MCP(a, b) memcpy(b,a,sizeof(b)) #define p(s) cout<<(s)<>N>>Px>>Py; REP(i,0,N){ cin>>cmd[i][0]; if(cmd[i][0] != 3) cin>>cmd[i][1]; } int routeCount = 0; REP(i,0,N){ if(cmd[i][0] == 3) routeCount++, rd[i] = 1; if(i > 0) rd[i] += rd[i-1]; } RREP(i,0,N){ if(cmd[i][0] == 3) { routeCount--; continue; } if(routeCount % 4 == 0){ if (cmd[i][0] == 1) movex[i] = cmd[i][1]; else movey[i] = cmd[i][1]; }else if(routeCount % 4 == 1) { if (cmd[i][0] == 1) movey[i] = -cmd[i][1]; else movex[i] = cmd[i][1]; }else if(routeCount % 4 == 2) { if (cmd[i][0] == 1) movex[i] = -cmd[i][1]; else movey[i] = -cmd[i][1]; }else if(routeCount % 4 == 3) { if (cmd[i][0] == 1) movey[i] = cmd[i][1]; else movex[i] = -cmd[i][1]; } } RREP(i,0,N-1){ movex[i] += movex[i+1]; movey[i] += movey[i+1]; } REP(i,0,N){ int x = Px + movex[i]; int y = Py + movey[i]; int ansx, ansy; int r =rd[N-1] - rd[i]; if(cmd[i][0] == 3) r++; if(r % 4 == 0){ ansx = x; ansy = y; }else if(r % 4 == 1) { ansx = y; ansy = -x; }else if(r % 4 == 2) { ansx = -x; ansy = -y; }else if(r % 4 == 3) { ansx = -y; ansy = x; } cout<