Problem:
Beyond the Former Explorer
You are standing at the very center of a field, which is divided into a grid of cells running north-south and east-west. A great treasure is hidden somewhere within one of these cells.
John Belzoni
, a descendant of the famous treasure hunter
Giovanni Battista Belzoni
, actually discovered that treasure. Unfortunately enough, he died of heatstroke before successfully digging it out; he seems to have spent too long time wandering around the field.
John started his exploration from the central cell of the field where you stand now. All of his footprints leading to the treasure are left on the field, but you cannot identify the footprint on a cell until you reach there. The footprint on a cell indicates which of the four adjacent grid cells he proceeded to. It is known that John did not visit the same grid cell twice or more. You see a footprint on the central cell indicating that
John’s first step was northward
.
There is exactly one treasure cell in the field, and you will recognize it only when you are on it.
A possible situation of the field is shown in Figure G.1. John’s footprints are depicted as arrows in the cells. The treasure cell is depicted as ‘
G
’. The shaded cell is where you initially stand.
Figure G.1. Possible situation
Your task is to find the treasure in a limited number of
steps
. In a single step, you decide to take one of the four directions north, west, south, or east, and proceed to the adjacent cell in that direction. When you move on to the cell, you may find either the treasure, John’s footprint, or nothing. You do not have to follow John’s footprints. Unlike John’s route, you may visit the same cell more than once. John’s footprints will remain the same regardless of your exploration.
Interaction
The interaction begins by receiving an integer $n$ ($1 \leq n \leq 2000$) from the standard input, followed by a newline. The integer $n$ means that the field is partitioned into $(2n + 1) \times (2n + 1)$ grid cells. You are initially on the cell $(n + 1)$-th from the west end and $(n + 1)$-th from the north end. After receiving the integer $n$, you can start your exploration steps.
In each step, you send a single character meaning the direction of the cell to move to: ‘
ˆ
’ (caret) for north, ‘
<
’ (less than symbol) for west, ‘
v
’ (lowercase V) for south, and ‘
>
’ (greater than symbol) for east. The character should be sent to the standard output followed by a newline.
In its response, you will receive a character indicating what you find on the cell you moved to, followed by a newline. The character ‘
G
’ means that the treasure is there. The characters ‘
ˆ
’, ‘
<
’, ‘
v
’, and ‘
>
’ mean John’s footprint directing north, west, south, and east, respectively. The character ‘
.
’ (dot) means neither the treasure nor a footprint is on the cell.
When you find the treasure, that is, when you have received the character ‘
G
’, the interaction stops and your program should terminate.
You must reach the 
...(truncated)

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto&& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sy = n + 1, sx = n + 1;
    string in;
    n *= 2;
    n ++;
    vector<string> s(n + 2, string(n + 2, '.'));
    s[sy][sx] = '^';

    int y = sy, x = sx;
    int intc = 0;
    auto process = [&](int gy, int gx) -> void {
        intc += abs(gy - y) + abs(gx - x);
        assert(intc <= 29900);
        // gy, gxまで進める
        while(y < gy) {
            y ++;
            cout << "v" << endl;
            cin >> in;
            if(in == "G") exit(0);
            s[y][x] = in[0];
        }
        while(y > gy) {
            y --;
            cout << "^" << endl;
            cin >> in;
            if(in == "G") exit(0);
            s[y][x] = in[0];
        }
        while(x < gx) {
            x ++;
            cout << ">" << endl;
            cin >> in;
            if(in == "G") exit(0);
            s[y][x] = in[0];
        }
        while(x > gx) {
            x --;
            cout << "<" << endl;
            cin >> in;
            if(in == "G") exit(0);
            s[y][x] = in[0];
        }
    };
    int ley = 1, riy = n + 1;
    int lex = 1, rix = n + 1;
    while(min(riy - ley, rix - lex) > 5) {
        int midx = (rix + lex) / 2;
        if(ley == 1 and riy == n + 1) {
            int Y = y;
            process(Y, midx);
            process(ley, midx);
            process(ley, midx + 1);
            process(riy - 1, midx + 1);
            process(riy - 1, midx);
            process(Y + 1, midx);
        } else {
            if(abs(riy - 1 - y) < abs(ley - y)) {
                process(riy - 1, midx);
                process(ley, midx);
                process(ley, midx + 1);
                process(riy - 1, midx + 1);
            } else {
                process(ley, midx);
                process(riy - 1, midx);
                process(riy - 1, midx + 1);
                process(ley, midx + 1);
            }
        }
            
        {
            int cnt = -(ley <= sy and sy < riy and lex <= sx and sx <= midx);
            for(int i = ley; i < riy; i ++) {
                if(s[i][lex] == '<') cnt ++;
                if(s[i][lex - 1] == '>') cnt --;
                if(s[i][midx] == '>') cnt ++;
                if(s[i][midx + 1] == '<') cnt --;
            }
            for(int i = lex; i <= midx; i ++) {
                if(s[ley][i] == '^') cnt ++;
                if(s[ley - 1][i] == 'v') cnt --;
                if(s[riy - 1][i] == 'v') cnt ++;
                if(s[riy][i] == '^') cnt --;
            }
            if(cnt == 0) {
                lex = midx + 1;
            } else {
                rix = midx + 1;
            }
        }
        int midy = (riy + ley) / 2;
        if(abs(rix - 1 - x) < abs(lex - x)) {
            process(midy, rix - 1);
            process(midy, lex);
            process(midy + 1, lex);
            process(midy + 1, rix - 1);
        } else {
            process(midy, lex);
            process(midy, rix - 1);
            process(midy + 1, rix - 1);
            process(midy + 1, lex);
        }
        {
            int cnt = -(ley <= sy and sy <= midy and lex <= sx and sx < rix);
            for(int i = lex; i < rix; i ++) {
                if(s[ley][i] == '^') cnt ++;
                if(s[ley - 1][i] == 'v') cnt --;
                if(s[midy][i] == 'v') cnt ++;
                if(s[midy + 1][i] == '^') cnt --;
            }
            for(int i = ley; i <= midy; i ++) {
                if(s[i][lex] == '<') cnt ++;
                if(s[i][lex - 1] == '>') cnt --;
                if(s[i][rix - 1] == '>') cnt ++;
                if(s[i][rix] == '<') cnt --;
            }
            if(cnt == 0) {
                ley = midy + 1;
            } else {
                riy = midy + 1;
            }
        }
    }
    for(int i = ley; i < riy; i ++) {
        if(i & 1) {
            process(i, lex);
            process(i, rix - 1);
        } else {
            process(i, rix - 1);
            process(i, lex);
        }
    }
    return 0;
}
accuracy: 1
time_ms: 320
memory_kb: 33792
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
 
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define rep(i,b) rng(i,0,b-1)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
#define per(i,b) gnr(i,b-1,0)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
typedef long long ll;
using pii=pair<int,int>;
using vi=vc<int>;
using uint=unsigned;
using ull=unsigned long long;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using t3=tuple<int,int,int>;
 
ll rand_int(ll l, ll r) { //[l, r]
    #ifdef LOCAL
    static mt19937_64 gen;
    #else
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    #endif
    return uniform_int_distribution<ll>(l, r)(gen);
}
 
template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<998244353>;
template<> const Mint Mint::G = Mint(3);


const int SZ = (1<<18);
#define N_ 401000

int n, w[4320][4320], DEB = 0;

char res[4320][4320]={
    "",
    ".........",
    ".........",
    "........",
    ".........",
    ".........",
    ".........",
    ".........",
    ".........",
};

int Query(int a, int x, int y){
    char p[10]=".^>v<", q[10];
    if(!DEB)printf("%c\n",p[a]);
    fflush(stdout);
    if(!DEB){
        scanf("%s",q);
    }
    else{
        q[0] = res[x][y];
        //printf("%c\n",q[0]);
    }
    if(q[0]=='G'){
        exit(0);
    }
    if(q[0]=='^')return 1;
    if(q[0]=='>')return 2;
    if(q[0]=='v')return 3;
    if(q[0]=='<')return 4;
    return 0;
}

void Go(int &x, int &y, int rx, int ry){
    while(x>rx){
        w[x-1][y] = Query(1,x-1,y); x--;
    }
    while(x<rx){
        w[x+1][y] = Query(3,x+1,y); x++;
    }
    while(y>ry){
        w[x][y-1] = Query(4,x,y-1); y--;
    }
    while(y<ry){
        w[x][y+1] = Query(2,x,y+1); y++;
    }
}

void Do(int bx, int by, int ex, int ey, int x, int y){
    if(DEB)printf("%d %d %d %d\n",bx,by,ex,ey);
    
    if(ex-bx<=1 && ey-by<=1)return;

    if(ex-bx<=3 || ey-by<=3){
        rng(i,bx,ex){
            rng(j,by,ey){
                Go(x,y,i,j);
            }
        }

    }
    int mx = (bx+ex)/2;
    int my = (by+ey)/2;

    if(ex-bx > ey-by){ // [mx,mx+1] x [by, ey]
        Go(x,y,mx,y);
        Go(x,y,mx,by);
        Go(x,y,mx,ey);
        Go(x,y,mx+1,ey);
        Go(x,y,mx+1,by);
        Go(x,y,mx+1,my);

        int in = 0, out = 0;
        rng(i,by,ey){
            if(w[mx+1][i] == 1)in+=2;
            if(w[mx][i] == 3)out+=2;
            
            if(w[bx][i] == 1)out+=2;
            if(w[bx-1][i] == 3)in+=2;
        }
        rng(i,bx,mx){
            if(w[i][ey+1] == 4)in+=2;
            if(w[i][ey] == 2)out+=2;

            if(w[i][by] == 4)out+=2;
            if(w[i][by-1] == 2)in+=2;
        }
        //printf("%d %d %d %d %d %d\n",in,out, bx, mx, by, ey);
        if(bx<=n+1 && n+1<=mx && by<=n+1 &&n+1<=ey)in++;
        else out++;

        if(in>out)Do(bx,by,mx,ey,x,y);
        else Do(mx+1,by,ex,ey,x,y);
    }
    else{
        Go(x,y,x,my);
        Go(x,y,bx,my);
        Go(x,y,ex,my);
        Go(x,y,ex,my+1);
        Go(x,y,bx,my+1);
        Go(x,y,mx,my+1);

        int in = 0, out = 0;
        rng(i,by,my){
            
            if(w[bx][i] == 1)out+=2;
            if(w[bx-1][i] == 3)in+=2;

            if(w[ex+1][i] == 1)in+=2;
            if(w[ex][i] == 3)out+=2;
        }
        //if(bx==3502&&by== 3877&&ex== 3626&&ey== 4001)printf("in out %d %d\n",in,out);

        rng(i,bx,ex){
            if(w[i][my+1] == 4)in+=2;
            if(w[i][my] == 2)out+=2;

            if(w[i][by] == 4)out+=2;
            if(w[i][by-1] == 2)in+=2;

            //if(bx==3502&&by== 3877&&ex== 3626&&ey== 4001)printf("%d%d%d%d\n",w[i][by-1],w[i][by],w[i][my],w[i][my+1]);
        }
        //printf("! %d %d %d %d %d %d\n",in,out, bx, ex, by, my);
        if(bx<=n+1 && n+1<=ex && by<=n+1 &&n+1<=my)in++;
        else out++;

        if(in>out)Do(bx,by,ex,my,x,y);
        else Do(bx,my+1,ex,ey,x,y);
    }
}
void Solve(){
    scanf("%d",&n);
    if(DEB){
        rng(i,3,n+1){
            res[i][n+1]='^';
            res[2][n-2+i]='>';
        }
        rng(i,2,n*2-1){
            res[i][n*2]='v';
        }
        gnr(i,n*2,3){
            res[n*2][i]='<';
        }
        gnr(i,n*2,n*2-468){
            if(i%2==0){
                res[i][2]='^';
                rng(j,2,n*2-5)res[i-1][j]='>';
            }
            else{
                res[i][2*n-4]='^';
                rng(j,3,n*2-4)res[i-1][j]='<';
            }
        }
        res[n*2-468-1][n*2-4]='G';
        rng(i,1,2*n+1){
            rng(j,1,2*n+1){
                //printf("%c",res[i][j]);
            }
            //puts("");
        }
        printf("R %d %d\n",n*2-468-1,n*2-4);
    }
    w[n+1][n+1] = 1;
    Do(1,1,2*n+1,2*n+1,n+1,n+1);
}
 
int main(){
	
    int TC=1;
    //scanf("%d",&TC);
    while(TC--){
        Solve();
    }
}
accuracy: 1
time_ms: 470
memory_kb: 71260
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
    qc++;
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		cout << " ask " << c << "end\n";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
    // t=min(t,n*2+1);
    // t=max(t,1);
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
    // t=min(t,n*2+1);
    // t=max(t,1);
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

bool inside (int l,int r,int u,int d){
    int cnt=0;
    for (int i=r;i>l;i--) if (a[d+1][i]=='^') cnt++;
    for (int i=r;i>l;i--) if (a[d][i]=='v') cnt--;
    for (int i=r;i>l;i--) if (a[u+1][i]=='^') cnt--;
    for (int i=r;i>l;i--) if (a[u][i]=='v') cnt++;
    for (int i=d;i>u;i--) if (a[i][l]=='>') cnt++;
    for (int i=d;i>u;i--) if (a[i][l+1]=='<') cnt--;
    for (int i=d;i>u;i--) if (a[i][r]=='>') cnt--;
    for (int i=d;i>u;i--) if (a[i][r+1]=='<') cnt++;
    if (cnt > 0 || (d>=n+1 && u+1<=n+1 && l+1<=n+1 && r>=n+1 && cnt==0)) return 1;
    return 0;
}

int main(){
	cin >> n;
    // char tmp='^';
    // while (1){
    //     tmp=ask(tmp);
    // }
	nr=n+1, nc=n+1;
	int l=0,u=0,r=2*n+1,d=2*n+1;
    while (1){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        int cnt=0;
        go_ud(mr);
        go_lr(l+1);
        go_lr(r);
        go_ud(mr+1);
        go_lr(l+1);
        go_lr(mc);
        if (inside(l,r,u,mr)){
            d=mr;
            go_ud(u+1);
            go_lr(nc+1);
            go_ud(d);
        }
        else{
            u=mr;
            go_ud(d);
            go_lr(nc+1);
            go_ud(u+1);
        }
        if (inside(mc,r,u,d)){
            l=mc;
        }
        else{
            r=mc;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 33484
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
    qc++;
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		cout << " ask " << c << "end\n";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
    t=min(t,n*2+1);
    t=max(t,1);
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
    t=min(t,n*2+1);
    t=max(t,1);
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

bool inside (int l,int r,int u,int d){
    int cnt=0;
    for (int i=r;i>l;i--) if (a[d+1][i]=='^') cnt++;
    for (int i=r;i>l;i--) if (a[d][i]=='v') cnt--;
    for (int i=r;i>l;i--) if (a[u+1][i]=='^') cnt--;
    for (int i=r;i>l;i--) if (a[u][i]=='v') cnt++;
    for (int i=d;i>u;i--) if (a[i][l]=='>') cnt++;
    for (int i=d;i>u;i--) if (a[i][l+1]=='<') cnt--;
    for (int i=d;i>u;i--) if (a[i][r]=='>') cnt--;
    for (int i=d;i>u;i--) if (a[i][r+1]=='<') cnt++;
    if (cnt > 0 || (d>=n+1 && u+1<=n+1 && l+1<=n+1 && r>=n+1 && cnt==0)) return 1;
    return 0;
}

int main(){
	cin >> n;
    // char tmp='^';
    // while (1){
    //     tmp=ask(tmp);
    // }
	nr=n+1, nc=n+1;
	int l=0,u=0,r=2*n+1,d=2*n+1;
    while (1){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        int cnt=0;
        go_ud(mr);
        go_lr(l+1);
        go_lr(r);
        go_ud(mr+1);
        go_lr(l+1);
        go_lr(mc);
        if (inside(l,r,u,mr)){
            d=mr;
            go_ud(u+1);
            go_lr(nc+1);
            go_ud(d);
        }
        else{
            u=mr;
            go_ud(d);
            go_lr(nc+1);
            go_ud(u+1);
        }
        if (inside(mc,r,u,d)){
            l=mc;
        }
        else{
            r=mc;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 33552
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
    qc++;
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		cout << " ask " << c << "end\n";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
    t=min(t,n*2+1);
    t=max(t,1);
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
    t=min(t,n*2+1);
    t=max(t,1);
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

bool inside (int l,int r,int u,int d){
    int cnt=0;
    for (int i=r;i>l;i--) if (a[d+1][i]=='^') cnt++;
    for (int i=r;i>l;i--) if (a[d][i]=='v') cnt--;
    for (int i=r;i>l;i--) if (a[u+1][i]=='^') cnt--;
    for (int i=r;i>l;i--) if (a[u][i]=='v') cnt++;
    for (int i=d;i>u;i--) if (a[i][l]=='>') cnt++;
    for (int i=d;i>u;i--) if (a[i][l+1]=='<') cnt--;
    for (int i=d;i>u;i--) if (a[i][r]=='>') cnt--;
    for (int i=d;i>u;i--) if (a[i][r+1]=='<') cnt++;
    if (cnt > 0 || (d>=n+1 && u+1<=n+1 && l+1<=n+1 && r>=n+1 && cnt==0)) return 1;
    return 0;
}

int main(){
	cin >> n;
    // char tmp='^';
    // while (1){
    //     tmp=ask(tmp);
    // }
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
	int l=0,u=0,r=2*n+1,d=2*n+1;
    while (1){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        int cnt=0;
        go_ud(mr);
        go_lr(l+1);
        go_lr(r);
        go_ud(mr+1);
        go_lr(l+1);
        go_lr(mc);
        if (inside(l,r,u,mr)){
            d=mr;
            go_ud(u+1);
            go_lr(nc+1);
            go_ud(d);
        }
        else{
            u=mr;
            go_ud(d);
            go_lr(nc+1);
            go_ud(u+1);
        }
        if (inside(mc,r,u,d)){
            l=mc;
        }
        else{
            r=mc;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 470
memory_kb: 33556
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

string S = "^<v>";
int dx[4] = {-1,0,1,0}, dy[4] = {0,-1,0,1};

int N;
int CurX, CurY;
vector<vector<int>> memo;

bool isin(int X, int Y) {
    return 0 <= X && X <= N*2 && 0 <= Y && Y <= N*2;
}

void query(int id) {
    CurX += dx[id], CurY += dy[id];
    cout << S[id] << endl;
    char ret;
    cin >> ret;
    if (ret == 'G') exit(0);
    memo[CurX][CurY] = ret;
}

void getto(int ToX, int ToY) {
    while(ToX < CurX) query(0);
    while(ToY < CurY) query(1);
    while(ToX > CurX) query(2);
    while(ToY > CurY) query(3);
}

int countin(int XL, int XR, int YL, int YR) {
    int Ret = 0;
    if (XL <= N && N < XR && YL <= N && N < YR) Ret++;
    rep(i,XL,XR) {
        if (YL-1 >= 0 && memo[i][YL-1] == '>') Ret++;
        if (memo[i][YL] == '<') Ret--;
        if (memo[i][YR-1] == '>') Ret--;
        if (YR <= N*2 && memo[i][YR] == '<') Ret++;
    }
    rep(j,YL,YR) {
        if (XL-1 >= 0 && memo[XL-1][j] == 'v') Ret++;
        if (memo[XL][j] == '^') Ret--;
        if (memo[XR-1][j] == 'v') Ret--;
        if (XR <= N*2 && memo[XR][j] == '^') Ret++;
    }
    return Ret;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> N;
    CurX = N, CurY = N;
    memo = vector<vector<int>>(N*2+1, vector<int>(N*2+1,' '));
    memo[N][N] = 0;
    int XL = 0, XR = N*2+1, YL = 0, YR = N*2+1;
    {
        int YM = N;
        getto(0,N);
        getto(0,N-1);
        getto(N*2,N-1);
        getto(N*2,N);
        getto(N+1,N);
        if (countin(XL,XR,YL,YM) == 1) YR = YM;
        else YL = YM;
    }
    while(1) {
        {
            int XM = (XL + XR) / 2;
            if (abs(YL-CurY) < abs(YR-CurY)) {
                getto(XM,YL);
                getto(XM,YR-1);
                getto(XM-1,YR-1);
                getto(XM-1,YL);
            }
            else {
                getto(XM,YR-1);
                getto(XM,YL);
                getto(XM-1,YL);
                getto(XM-1,YR-1);
            }
            if (countin(XL,XM,YL,YR) == 1) XR = XM;
            else XL = XM;
        }
        {
            int YM = (YL + YR) / 2;
            if (abs(XL-CurX) < abs(XR-CurX)) {
                getto(XL,YM);
                getto(XR-1,YM);
                getto(XR-1,YM-1);
                getto(XL,YM-1);
            }
            else {
                getto(XR-1,YM);
                getto(XL,YM);
                getto(XL,YM-1);
                getto(XR-1,YM-1);
            }
            if (countin(XL,XR,YL,YM) == 1) YR = YM;
            else YL = YM;
        }
    }
}
accuracy: 1
time_ms: 460
memory_kb: 65816
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pt;
#define FOR(i,l,r) for(ll i=(l);i<(r);i++)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
int main(){
  ll N;cin>>N;

  // vector<string>ans(2*N+1);
  // REP(i,2*N+1)cin>>ans[i];

  vector<string>S(2*N+1,string(2*N+1,'_'));
  ll x=N,y=N;
  auto ask=[&](char c){
    cout<<c<<endl;
    if(c=='^')x--;
    else if(c=='v')x++;
    else if(c=='<')y--;
    else if(c=='>')y++;
    else assert(0);
    cin>>S[x][y];
    //S[x][y]=ans[x][y];
    return S[x][y];
  };
  bool end;
  auto go=[&](ll dx,ll dy){
    end=1;
    while(x!=dx||y!=dy){
      if(x<dx){if(ask('v')=='G')return;}
      else if(x>dx){if(ask('^')=='G')return;}
      else if(y<dy){if(ask('>')=='G')return;}
      else{if(ask('<')=='G')return;}
    }
    end=0;
    return;
  };
  REP(i,N)if(ask('^')=='G')return 0;
  if(ask('>')=='G')return 0;
  REP(i,2*N)if(ask('v')=='G')return 0;
  if(ask('<')=='G')return 0;
  REP(i,N)if(ask('^')=='G')return 0;
  ll c=0;
  REP(i,2*N+1){
    if(S[i][N]=='>')c++;
    if(S[i][N+1]=='<')c--;
  }
  assert(c==0||c==1);
  ll u=0,d=2*N+1,l=0,r=2*N+1;
  if(c)l=N+2;
  else r=N;
  while(1){
    if(d-u>r-l){
      ll m=(u+d)/2;
      if(abs(l-y)<abs(r-1-y)){
        go(m,l);
        if(end)return 0;
        go(m,r-1);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
      }
      else{
        go(m,r-1);
        if(end)return 0;
        go(m,l);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,l-1,r+1)if(0<=x&&x<=2*N){
        if(S[m-1][x]=='v')in--;
        if(S[m][x]=='^')in++;
        if(u<2)continue;
        if(S[u-2][x]=='v')in++;
        if(S[u-1][x]=='^')in--;
      }
      FOR(x,u-1,m)if(0<=x&&x<=2*N){
        if(l>=2){
          if(S[x][l-2]=='>')in++;
          if(S[x][l-1]=='<')in--;
        }
        if(r<2*N){
          if(S[x][r]=='>')in--;
          if(S[x][r+1]=='<')in++;
        }
      }
      if(u-1<=N&&N<=m-1&&l-1<=N&&N<=r)in++;
      assert(in==0||in==1);
      if(in==0)u=m+1;
      else d=m-1;
    }
    else{
      ll m=(l+r)/2;
      if(abs(x-u)<abs(x-d+1)){
        go(u,m);
        if(end)return 0;
        go(d-1,m);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
      }
      else{
        go(d-1,m);
        if(end)return 0;
        go(u,m);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,u-1,d+1)if(0<=x&&x<=2*N){
        if(S[x][m-1]=='>')in--;
        if(S[x][m]=='<')in++;
        if(l<2)continue;
        if(S[x][l-2]=='>')in++;
        if(S[x][l-1]=='<')in--;
      }
      FOR(x,l-1,m)if(0<=x&&x<=2*N){
        if(u>=2){
          if(S[u-2][x]=='v')in++;
          if(S[u-1][x]=='^')in--;
        }
        if(d<2*N){
          if(S[d][x]=='v')in--;
          if(S[d+1][x]=='^')in++;
        }
      }
      if(l-1<=N&&N<=m-1&&u-1<=N&&N<=d)in++;
      assert(in==0||in==1);
      if(in==0)l=m+1;
      else r=m-1;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 450
memory_kb: 33552
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pt;
#define FOR(i,l,r) for(ll i=(l);i<(r);i++)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
int main(){
  ll N;cin>>N;

  // vector<string>ans(2*N+1);
  // REP(i,2*N+1)cin>>ans[i];

  vector<string>S(2*N+1,string(2*N+1,'_'));
  ll x=N,y=N;
  auto ask=[&](char c){
    cout<<c<<endl;
    if(c=='^')x--;
    else if(c=='v')x++;
    else if(c=='<')y--;
    else if(c=='>')y++;
    else assert(0);
    cin>>S[x][y];
    //S[x][y]=ans[x][y];
    return S[x][y];
  };
  bool end;
  auto go=[&](ll dx,ll dy){
    end=1;
    while(x!=dx||y!=dy){
      if(x<dx){if(ask('v')=='G')return;}
      else if(x>dx){if(ask('^')=='G')return;}
      else if(y<dy){if(ask('>')=='G')return;}
      else{if(ask('<')=='G')return;}
    }
    end=0;
    return;
  };
  REP(i,N)if(ask('^')=='G')return 0;
  if(ask('>')=='G')return 0;
  REP(i,2*N)if(ask('v')=='G')return 0;
  if(ask('<')=='G')return 0;
  REP(i,N)if(ask('^')=='G')return 0;
  ll c=0;
  REP(i,2*N+1){
    if(S[i][N]=='>')c++;
    if(S[i][N+1]=='<')c--;
  }
  assert(c==0||c==1);
  ll u=0,d=2*N+1,l=0,r=2*N+1;
  if(c)l=N+2;
  else r=N;
  while(1){
    if(d-u>r-l){
      ll m=(u+d)/2;
      if(abs(l-y)<abs(r-1-y)){
        go(m,l);
        if(end)return 0;
        go(m,r-1);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
      }
      else{
        go(m,r-1);
        if(end)return 0;
        go(m,l);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,l-1,r+1)if(0<=x&&x<=2*N){
        if(S[m-1][x]=='v')in--;
        if(S[m][x]=='^')in++;
        if(u<2)continue;
        if(S[u-2][x]=='v')in++;
        if(S[u-1][x]=='^')in--;
      }
      FOR(x,u-1,m)if(0<=x&&x<=2*N){
        if(l>=2){
          if(S[x][l-2]=='>')in++;
          if(S[x][l-1]=='<')in--;
        }
        if(r<2*N){
          if(S[x][r]=='>')in--;
          if(S[x][r+1]=='<')in++;
        }
      }
      if(l-1<=N&&N<=m-1&&u-1<=N&&N<=d)in++;
      assert(in==0||in==1);
      if(in==0)u=m+1;
      else d=m-1;
    }
    else{
      ll m=(l+r)/2;
      if(abs(x-u)<abs(x-d+1)){
        go(u,m);
        if(end)return 0;
        go(d-1,m);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
      }
      else{
        go(d-1,m);
        if(end)return 0;
        go(u,m);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,u-1,d+1)if(0<=x&&x<=2*N){
        if(S[x][m-1]=='>')in--;
        if(S[x][m]=='<')in++;
        if(l<2)continue;
        if(S[x][l-2]=='>')in++;
        if(S[x][l-1]=='<')in--;
      }
      FOR(x,l-1,m)if(0<=x&&x<=2*N){
        if(u>=2){
          if(S[u-2][x]=='v')in++;
          if(S[u-1][x]=='^')in--;
        }
        if(d<2*N){
          if(S[d][x]=='v')in--;
          if(S[d+1][x]=='^')in++;
        }
      }
      if(u-1<=N&&N<=m-1&&l-1<=N&&N<=r)in++;
      assert(in==0||in==1);
      if(in==0)l=m+1;
      else r=m-1;
    }
  }
  return 0;
}
accuracy: 0.19148936170212766
time_ms: 280
memory_kb: 16484
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pt;
#define FOR(i,l,r) for(ll i=(l);i<(r);i++)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
int main(){
  ll N;cin>>N;

  // vector<string>ans(2*N+1);
  // REP(i,2*N+1)cin>>ans[i];

  vector<string>S(2*N+1,string(2*N+1,'_'));
  ll x=N,y=N;
  auto ask=[&](char c){
    cout<<c<<endl;
    if(c=='^')x--;
    else if(c=='v')x++;
    else if(c=='<')y--;
    else if(c=='>')y++;
    else assert(0);
    cin>>S[x][y];
    //S[x][y]=ans[x][y];
    return S[x][y];
  };
  bool end;
  auto go=[&](ll dx,ll dy){
    end=1;
    while(x!=dx||y!=dy){
      if(x<dx){if(ask('v')=='G')return;}
      else if(x>dx){if(ask('^')=='G')return;}
      else if(y<dy){if(ask('>')=='G')return;}
      else{if(ask('<')=='G')return;}
    }
    end=0;
    return;
  };
  REP(i,N)if(ask('^')=='G')return 0;
  if(ask('>')=='G')return 0;
  REP(i,2*N)if(ask('v')=='G')return 0;
  if(ask('<')=='G')return 0;
  REP(i,N)if(ask('^')=='G')return 0;
  ll c=0;
  REP(i,2*N+1){
    if(S[i][N]=='>')c++;
    if(S[i][N+1]=='<')c--;
  }
  assert(c==0||c==1);
  ll u=0,d=2*N+1,l=0,r=2*N+1;
  if(c)l=N+2;
  else r=N;
  while(1){
    if(d-u>r-l){
      ll m=(u+d)/2;
      if(abs(l-y)<abs(r-1-y)){
        go(m,l);
        if(end)return 0;
        go(m,r-1);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
      }
      else{
        go(m,r-1);
        if(end)return 0;
        go(m,l);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,l-1,r+1)if(0<=x&&x<=2*N){
        if(S[m-1][x]=='v')in--;
        if(S[m][x]=='^')in++;
        if(u<2)continue;
        if(S[u-2][x]=='v')in++;
        if(S[u-1][x]=='^')in--;
      }
      FOR(x,u-1,m)if(0<=x&&x<=2*N){
        if(l>=2){
          if(S[x][l-2]=='>')in++;
          if(S[x][l-1]=='<')in--;
        }
        if(r<2*N){
          if(S[x][r]=='>')in--;
          if(S[x][r+1]=='<')in++;
        }
      }
      if(in==0)u=m+1;
      else d=m-1;
    }
    else{
      ll m=(l+r)/2;
      if(abs(x-u)<abs(x-d+1)){
        go(u,m);
        if(end)return 0;
        go(d-1,m);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
      }
      else{
        go(d-1,m);
        if(end)return 0;
        go(u,m);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,u-1,d+1)if(0<=x&&x<=2*N){
        if(S[x][m-1]=='>')in--;
        if(S[x][m]=='<')in++;
        if(l<2)continue;
        if(S[x][l-2]=='>')in++;
        if(S[x][l-1]=='<')in--;
      }
      FOR(x,l-1,m)if(0<=x&&x<=2*N){
        if(u>=2){
          if(S[u-2][x]=='v')in++;
          if(S[u-1][x]=='^')in--;
        }
        if(d<2*N){
          if(S[d][x]=='v')in--;
          if(S[d+1][x]=='^')in++;
        }
      }
      if(in==0)l=m+1;
      else r=m-1;
    }
  }
  return 0;
}
accuracy: 0.2127659574468085
time_ms: 280
memory_kb: 16148
final_rank: 17

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pt;
#define FOR(i,l,r) for(ll i=(l);i<(r);i++)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
int main(){
  ll N;cin>>N;

  // vector<string>ans(2*N+1);
  // REP(i,2*N+1)cin>>ans[i];

  vector<string>S(2*N+1,string(2*N+1,'_'));
  ll x=N,y=N;
  auto ask=[&](char c){
    cout<<c<<endl;
    if(c=='^')x--;
    else if(c=='v')x++;
    else if(c=='<')y--;
    else if(c=='>')y++;
    else assert(0);
    cin>>S[x][y];
    //S[x][y]=ans[x][y];
    return S[x][y];
  };
  bool end;
  auto go=[&](ll dx,ll dy){
    end=1;
    while(x!=dx||y!=dy){
      if(x<dx){if(ask('v')=='G')return;}
      else if(x>dx){if(ask('^')=='G')return;}
      else if(y<dy){if(ask('>')=='G')return;}
      else{if(ask('<')=='G')return;}
    }
    end=0;
    return;
  };
  REP(i,N)if(ask('^')=='G')return 0;
  if(ask('>')=='G')return 0;
  REP(i,2*N)if(ask('v')=='G')return 0;
  if(ask('<')=='G')return 0;
  REP(i,N)if(ask('^')=='G')return 0;
  ll c=0;
  REP(i,2*N+1){
    if(S[i][N]=='>')c++;
    if(S[i][N+1]=='<')c--;
  }
  assert(c==0||c==1);
  ll u=0,d=2*N+1,l=0,r=2*N+1;
  if(c)l=N+2;
  else r=N;
  while(1){
    if(d-u>r-l){
      ll m=(u+d)/2;
      if(abs(l-y)<abs(r-1-y)){
        go(m,l);
        if(end)return 0;
        go(m,r-1);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
      }
      else{
        go(m,r-1);
        if(end)return 0;
        go(m,l);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,l-1,r+1)if(0<=x&&x<=2*N){
        if(S[m-1][x]=='v')in--;
        if(S[m][x]=='^')in++;
        if(u<2)continue;
        if(S[u-2][x]=='v')in++;
        if(S[u-1][x]=='^')in--;
      }
      FOR(x,u-1,m)if(0<=x&&x<=2*N){
        if(l>=2){
          if(S[x][l-2]=='>')in++;
          if(S[x][l-1]=='<')in--;
        }
        if(r<2*N){
          if(S[x][r]=='>')in--;
          if(S[x][r+1]=='<')in++;
        }
      }
      assert(in==0||in==1);
      if(in==0)u=m+1;
      else d=m-1;
    }
    else{
      ll m=(l+r)/2;
      if(abs(x-u)<abs(x-d+1)){
        go(u,m);
        if(end)return 0;
        go(d-1,m);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
      }
      else{
        go(d-1,m);
        if(end)return 0;
        go(u,m);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,u-1,d+1)if(0<=x&&x<=2*N){
        if(S[x][m-1]=='>')in--;
        if(S[x][m]=='<')in++;
        if(l<2)continue;
        if(S[x][l-2]=='>')in++;
        if(S[x][l-1]=='<')in--;
      }
      FOR(x,l-1,m)if(0<=x&&x<=2*N){
        if(u>=2){
          if(S[u-2][x]=='v')in++;
          if(S[u-1][x]=='^')in--;
        }
        if(d<2*N){
          if(S[d][x]=='v')in--;
          if(S[d+1][x]=='^')in++;
        }
      }
      assert(in==0||in==1);
      if(in==0)l=m+1;
      else r=m-1;
    }
  }
  return 0;
}
accuracy: 0.2127659574468085
time_ms: 280
memory_kb: 16516
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef pair<ld,ld> pt;
#define FOR(i,l,r) for(ll i=(l);i<(r);i++)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
int main(){
  ll N;cin>>N;
  vector<string>S(2*N+1,string(2*N+1,'_'));
  ll x=N,y=N;
  auto ask=[&](char c){
    cout<<c<<endl;
    if(c=='^')x--;
    else if(c=='v')x++;
    else if(c=='<')y--;
    else if(c=='>')y++;
    else assert(0);
    cin>>S[x][y];

    //
    // vector<string>ans={
    //   "..>v.",
    //   "G.^.v",
    //   "^<^.v",
    //   ".^..v",
    //   ".^<<<"
    // };
    // S[x][y]=ans[x][y];
    //

    return S[x][y];
  };
  bool end;
  auto go=[&](ll dx,ll dy){
    end=1;
    while(x!=dx||y!=dy){
      if(x<dx){if(ask('v')=='G')return;}
      else if(x>dx){if(ask('^')=='G')return;}
      else if(y<dy){if(ask('>')=='G')return;}
      else{if(ask('<')=='G')return;}
    }
    end=0;
    return;
  };
  REP(i,N)if(ask('^')=='G')return 0;
  if(ask('>')=='G')return 0;
  REP(i,2*N)if(ask('v')=='G')return 0;
  if(ask('<')=='G')return 0;
  REP(i,N)if(ask('^')=='G')return 0;
  ll c=0;
  REP(i,2*N+1){
    if(S[i][N]=='>')c++;
    if(S[i][N+1]=='<')c--;
  }
  assert(c==0||c==1);
  ll u=0,d=2*N+1,l=0,r=2*N+1;
  if(c)l=N+2;
  else r=N;
  while(1){
    if(d-u>r-l){
      ll m=(u+d)/2;
      if(abs(l-y)<abs(r-1-y)){
        go(m,l);
        if(end)return 0;
        go(m,r-1);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
      }
      else{
        go(m,r-1);
        if(end)return 0;
        go(m,l);
        if(end)return 0;
        go(m-1,l);
        if(end)return 0;
        go(m-1,r-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,l-1,r+1)if(0<=x&&x<=2*N){
        if(S[m-1][x]=='v')in--;
        if(S[m][x]=='^')in++;
        if(u<2)continue;
        if(S[u-2][x]=='v')in++;
        if(S[u-1][x]=='^')in--;
      }
      FOR(x,u-1,m)if(0<=x&&x<=2*N){
        if(l>=2){
          if(S[x][l-2]=='>')in++;
          if(S[x][l-1]=='<')in--;
        }
        if(r<2*N){
          if(S[x][r]=='>')in--;
          if(S[x][r+1]=='<')in++;
        }
      }
      assert(in==0||in==1);
      if(in==0)u=m+1;
      else d=m-1;
    }
    else{
      ll m=(l+r)/2;
      if(abs(x-u)<abs(x-d+1)){
        go(u,m);
        if(end)return 0;
        go(d-1,m);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
      }
      else{
        go(d-1,m);
        if(end)return 0;
        go(u,m);
        if(end)return 0;
        go(u,m-1);
        if(end)return 0;
        go(d-1,m-1);
        if(end)return 0;
      }
      ll in=0;
      FOR(x,u-1,d+1)if(0<=x&&x<=2*N){
        if(S[x][m-1]=='>')in--;
        if(S[x][m]=='<')in++;
        if(l<2)continue;
        if(S[x][l-2]=='>')in++;
        if(S[x][l-1]=='<')in--;
      }
      FOR(x,l-1,m)if(0<=x&&x<=2*N){
        if(u>=2){
          if(S[u-2][x]=='v')in++;
          if(S[u-1][x]=='^')in--;
        }
        if(d<2*N){
          if(S[d][x]=='v')in--;
          if(S[d+1][x]=='^')in++;
        }
      }
      assert(in==0||in==1);
      if(in==0)l=m+1;
      else r=m-1;
    }
  }
  return 0;
}
accuracy: 0.2127659574468085
time_ms: 280
memory_kb: 16520
final_rank: 19

code_snippet: #include <bits/extc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define updiv(a, b) (((a) + (b) - 1) / (b))
using ll = long long;
using ull = unsigned long long;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1000000007;
constexpr int mod2 = 998244353;

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T, class It = decltype(std::begin(std::declval<T>()))>
inline constexpr auto Indexed(T&& iterable) {
    struct Iterator {
        size_t index;
        It it;
        constexpr bool operator!= (const Iterator& other) const { return it != other.it; }
        constexpr void operator++() { ++index; ++it; }
        constexpr void operator--() { --index; --it; }
        constexpr auto operator*() const { return std::tie(index, *it); }
    };
    struct IterableWrapper {
        T iterable;
        constexpr auto begin() { return Iterator{ 0, std::begin(iterable) }; }
        constexpr auto end() { return Iterator{ std::size(iterable), std::end(iterable) }; }
    };
    return IterableWrapper{ std::forward<T>(iterable) };
}

// {f(i) | i in [begin, left) ∪ (right, rbegin]}
template<class It, class F>
pair<It, reverse_iterator<It> > bsearch(It begin, It end, const F &f) {
    auto rbegin = reverse_iterator(end), rend = reverse_iterator(begin);
    if (begin == end) return make_pair(end, rend);
    It left; reverse_iterator<It> right;
    if (f(*begin)) {
        auto l = begin, r = end;
        while (r - l > 1) {
            auto mid = l + (r - l) / 2;
            if (f(*mid)) l = mid; else r = mid;
        }
        left = r;
    } else left = begin;
    if (f(*rbegin)) {
        auto l = rbegin, r = rend;
        while (r - l > 1) {
            auto mid = l + (r - l) / 2;
            if (f(*mid)) l = mid; else r = mid;
        }
        right = r;
    } else right = rbegin;
    return make_pair(left, right);
}

template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p){ is >> p.first >> p.second; return (is); }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p){ os << p.first << ' ' << p.second; return (os); }
template<class T> istream& operator>>(istream& is, vector<T>& v){ for (auto &&e : v) is >> e; return (is); }
template<class T> ostream& operator<<(ostream& os, vector<T>& v){ for (auto &&e : v) os << e << ' '; return (os); }

template<class T> inline const T& max(const vector<T> &v) { return *max_element(v.begin(), v.end()); }
template<class T> inline const T& min(const vector<T> &v) { return *min_element(v.begin(), v.end()); }
template<class T> inline T mex(vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (T i = 0; i < (T) v.size(); ++i) if (v[i] != i) return i;
    return v.size();
}
template<class T> inline T mex(initializer_list<T> l) { return mex(vector<T>(l)); }

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class A, class B> using umap = unordered_map<A, B>;
template <class T> using uset = unordered_set<T>;

template <class T> using Max_Heap = __gnu_pbds::priority_queue<T, less<T>, __gnu_pbds::rc_binomial_heap_tag>;
template <class T> using Min_Heap = __gnu_pbds::priority_queue<T, greater<T>, __gnu_pbds::rc_binomial_heap_tag>;
template <class T> using Set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class K, class V> using Umap = __gnu_pbds::gp_hash_table<K, V>;
template <class T> using Rope = __gnu_cxx::rope<T>;

template <class T> void bye(T x){ cout << x << '\n'; exit(0); }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1,0};
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1,0};
constexpr char ch[] = {'>', 'v', '<', '^', '.', 'G'};

char query(char c) {
    char ret;
    cout << c << endl;
    cin >> ret;
    if (ret == 'G') exit(0);
    return ret;
}

vector<vector<char> > mat;
int n, m;

bool has_goal(int u, int l, int d, int r) {
    int res = 0;
    if (u <= m + 1 && m + 1 <= d && l <= m + 1 && m + 1 <= r) res = 1;
    for (int i = u; i <= d; ++i) {
        if (mat[i][l - 1] == '>') res++;
        if (mat[i][r + 1] == '<') res++;
        if (mat[i][l] == '<') res--;
        if (mat[i][r] == '>') res--;
    }
    for (int j = l; j <= r; ++j) {
        if (mat[u - 1][j] == 'v') res++;
        if (mat[d + 1][j] == '^') res++;
        if (mat[u][j] == '^') res--;
        if (mat[d][j] == 'v') res--;
    }
    return res > 0;
}

void dfs(int u, int l, int d, int r, int cr, int cc, bool ver) {
    int dcr = cr, dcc = cc;
    char tmp;
    if (ver) {
        while (cr < d) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = tmp;
        }
        if (cc < r) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = tmp;
        }
        while (cr > u) {
            cr--;
            tmp = query('^');
            mat[cr][cc] = tmp;
        }
        if (cc > l) {
            cc--;
            tmp = query('<');
            mat[cr][cc] = tmp;
        }
        while (cr < dcr) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = tmp;
        }
        if (has_goal(u, l, d, dcc)) {
            while (cc > (l + dcc) / 2) {
                cc--;
                tmp = query('<');;
                mat[cr][cc] = tmp;
            }
            dfs(u, l, d, dcc, cr, cc, !ver);
        } else {
            while (cc < (dcc + 1 + r) / 2) {
                cc++;
                tmp = query('>');;
                mat[cr][cc] = tmp;
            }
            dfs(u, dcc + 1, d, r, cr, cc, !ver);
        }
    } else {
        while (cc < r) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = tmp;
        }
        if (cr < d) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = tmp;
        }
        while (cc > l) {
            cc--;
            tmp = query('<');
            mat[cr][cc] = tmp;
        }
        if (cr > u) {
            cr--;
            tmp = query('^');
            mat[cr][cc] = tmp;
        }
        while (cc < dcc) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = tmp;
        }
        if (has_goal(u, l, dcr, r)) {
            while (cr > (u + dcr) / 2) {
                cr--;
                tmp = query('^');;
                mat[cr][cc] = tmp;
            }
            dfs(u, l, dcr, r, cr, cc, !ver);
        } else {
            while (cr < (dcr + 1 + d) / 2) {
                cr++;
                tmp = query('v');;
                mat[cr][cc] = tmp;
            }
            dfs(dcr + 1, l, d, r, cr, cc, !ver);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    cin >> n;

    m = n;

    n = n * 2 + 1;

    mat = vector(n + 2, vector(n + 2, '~'));

    for (int i = 0; i < n + 2; ++i) {
        mat[i][0] = '<';
        mat[i][n + 1] = '>';
        mat[0][i] = '^';
        mat[n + 1][i] = 'v';
    }

    dfs(1, 1, n, n, m + 1, m + 1, true);

    return (0);
}
accuracy: 1
time_ms: 450
memory_kb: 33552
final_rank: 2

code_snippet: #include <bits/extc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) begin(x),end(x)
#define updiv(a, b) (((a) + (b) - 1) / (b))
using ll = long long;
using ull = unsigned long long;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1000000007;
constexpr int mod2 = 998244353;

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T, class It = decltype(std::begin(std::declval<T>()))>
inline constexpr auto Indexed(T&& iterable) {
    struct Iterator {
        size_t index;
        It it;
        constexpr bool operator!= (const Iterator& other) const { return it != other.it; }
        constexpr void operator++() { ++index; ++it; }
        constexpr void operator--() { --index; --it; }
        constexpr auto operator*() const { return std::tie(index, *it); }
    };
    struct IterableWrapper {
        T iterable;
        constexpr auto begin() { return Iterator{ 0, std::begin(iterable) }; }
        constexpr auto end() { return Iterator{ std::size(iterable), std::end(iterable) }; }
    };
    return IterableWrapper{ std::forward<T>(iterable) };
}

// {f(i) | i in [begin, left) ∪ (right, rbegin]}
template<class It, class F>
pair<It, reverse_iterator<It> > bsearch(It begin, It end, const F &f) {
    auto rbegin = reverse_iterator(end), rend = reverse_iterator(begin);
    if (begin == end) return make_pair(end, rend);
    It left; reverse_iterator<It> right;
    if (f(*begin)) {
        auto l = begin, r = end;
        while (r - l > 1) {
            auto mid = l + (r - l) / 2;
            if (f(*mid)) l = mid; else r = mid;
        }
        left = r;
    } else left = begin;
    if (f(*rbegin)) {
        auto l = rbegin, r = rend;
        while (r - l > 1) {
            auto mid = l + (r - l) / 2;
            if (f(*mid)) l = mid; else r = mid;
        }
        right = r;
    } else right = rbegin;
    return make_pair(left, right);
}

template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p){ is >> p.first >> p.second; return (is); }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p){ os << p.first << ' ' << p.second; return (os); }
template<class T> istream& operator>>(istream& is, vector<T>& v){ for (auto &&e : v) is >> e; return (is); }
template<class T> ostream& operator<<(ostream& os, vector<T>& v){ for (auto &&e : v) os << e << ' '; return (os); }

template<class T> inline const T& max(const vector<T> &v) { return *max_element(v.begin(), v.end()); }
template<class T> inline const T& min(const vector<T> &v) { return *min_element(v.begin(), v.end()); }
template<class T> inline T mex(vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (T i = 0; i < (T) v.size(); ++i) if (v[i] != i) return i;
    return v.size();
}
template<class T> inline T mex(initializer_list<T> l) { return mex(vector<T>(l)); }

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class A, class B> using umap = unordered_map<A, B>;
template <class T> using uset = unordered_set<T>;

template <class T> using Max_Heap = __gnu_pbds::priority_queue<T, less<T>, __gnu_pbds::rc_binomial_heap_tag>;
template <class T> using Min_Heap = __gnu_pbds::priority_queue<T, greater<T>, __gnu_pbds::rc_binomial_heap_tag>;
template <class T> using Set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class K, class V> using Umap = __gnu_pbds::gp_hash_table<K, V>;
template <class T> using Rope = __gnu_cxx::rope<T>;

template <class T> void bye(T x){ cout << x << '\n'; exit(0); }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1,0};
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1,0};
constexpr char ch[] = {'>', 'v', '<', '^', '.', 'G'};

int conv(char c) {
    for (int i = 0; i < sizeof(ch); ++i) {
        if (ch[i] == c) return i;
    }
    return -1;
}

char query(char c) {
    char ret;
    cout << c << endl;
    cin >> ret;
    if (ret == 'G') exit(0);
    return ret;
}

vector<vector<int> > mat;
int n, m;

bool has_goal(int u, int l, int d, int r) {
    int res = 0;
    if (u <= m + 1 && m + 1 <= d && l <= m + 1 && m + 1 <= r) res = 1;
    for (int i = u; i <= d; ++i) {
        if (mat[i][l - 1] == conv('>')) res++;
        if (mat[i][r + 1] == conv('<')) res++;
        if (mat[i][l] == conv('<')) res--;
        if (mat[i][r] == conv('>')) res--;
    }
    for (int j = l; j <= r; ++j) {
        if (mat[u - 1][j] == conv('v')) res++;
        if (mat[d + 1][j] == conv('^')) res++;
        if (mat[u][j] == conv('^')) res--;
        if (mat[d][j] == conv('v')) res--;
    }
    return res > 0;
}

void dfs(int u, int l, int d, int r, int cr, int cc, bool ver) {
    int dcr = cr, dcc = cc;
    char tmp;
    if (ver) {
        while (cr < d) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = conv(tmp);
        }
        if (cc < r) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = conv(tmp);
        }
        while (cr > u) {
            cr--;
            tmp = query('^');
            mat[cr][cc] = conv(tmp);
        }
        if (cc > l) {
            cc--;
            tmp = query('<');
            mat[cr][cc] = conv(tmp);
        }
        while (cr < dcr) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = conv(tmp);
        }
        if (has_goal(u, l, d, dcc)) {
            while (cc > (l + dcc) / 2) {
                cc--;
                tmp = query('<');;
                mat[cr][cc] = conv(tmp);
            }
            dfs(u, l, d, dcc, cr, cc, !ver);
        } else {
            while (cc < (dcc + 1 + r) / 2) {
                cc++;
                tmp = query('>');;
                mat[cr][cc] = conv(tmp);
            }
            dfs(u, dcc + 1, d, r, cr, cc, !ver);
        }
    } else {
        while (cc < r) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = conv(tmp);
        }
        if (cr < d) {
            cr++;
            tmp = query('v');
            mat[cr][cc] = conv(tmp);
        }
        while (cc > l) {
            cc--;
            tmp = query('<');
            mat[cr][cc] = conv(tmp);
        }
        if (cr > u) {
            cr--;
            tmp = query('^');
            mat[cr][cc] = conv(tmp);
        }
        while (cc < dcc) {
            cc++;
            tmp = query('>');
            mat[cr][cc] = conv(tmp);
        }
        if (has_goal(u, l, dcr, r)) {
            while (cr > (u + dcr) / 2) {
                cr--;
                tmp = query('^');;
                mat[cr][cc] = conv(tmp);
            }
            dfs(u, l, dcr, r, cr, cc, !ver);
        } else {
            while (cr < (dcr + 1 + d) / 2) {
                cr++;
                tmp = query('v');;
                mat[cr][cc] = conv(tmp);
            }
            dfs(dcr + 1, l, d, r, cr, cc, !ver);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    cin >> n;

    m = n;

    n = n * 2 + 1;

    mat = vector(n + 2, vector(n + 2, -1));

    for (int i = 0; i < n + 2; ++i) {
        mat[i][0] = conv('<');
        mat[i][n + 1] = conv('>');
        mat[0][i] = conv('^');
        mat[n + 1][i] = conv('v');
    }

    dfs(1, 1, n, n, m + 1, m + 1, true);

    return (0);
}
accuracy: 1
time_ms: 460
memory_kb: 65920
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
	int l=1,u=1,r=2*n+1,d=2*n+1;
    while (l<=r && u<=d){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        if (mr==n+1 && mc==n+1) mc++;
        int cnt=0;
        go_ud(mr);
        go_lr(l);
        go_lr(r);
        go_lr(mc);
        for (int i=u;i<mr;i++){
            if (a[i][l-1]=='>') cnt++;
            if (a[i][l-1]=='<') cnt--;
        }
        for (int i=u;i<mr;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=l;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=l;i<=r;i++){
            if (a[mr][i]=='v') cnt--;
            if (a[mr][i]=='^') cnt++;
        }
        if (cnt > 0 || (cnt == 0 && mr > n+1)){
            d=mr-1;
            go_ud(u);
        }
        else{
            u=mr+1;
            go_ud(d);
        }
        cnt=0;
        for (int i=u;i<=d;i++){
            if (a[i][mc]=='>') cnt++;
            if (a[i][mc]=='<') cnt--;
        }
        for (int i=u;i<=d;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[d+1][i]=='v') cnt--;
            if (a[d+1][i]=='^') cnt++;
        }
        if (cnt > 0){
            l=mc+1;
        }
        else{
            r=mc-1;
        }
    }
    go_lr(n+1);
    go_ud(n+1);
    char tmp='^';
    while (1){
        tmp=ask(tmp);
    }
    return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 33556
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
    // if ((2*n+1)*(2*n+1)<30000){
    //     char tmp='^';
    //     while (1){
    //     	tmp=ask(tmp);
    //     }
    // }
	int l=1,u=1,r=2*n+1,d=2*n+1;
    while (1){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        if (mr==n+1 && mc==n+1) mc++;
        int cnt=0;
        go_ud(mr);
        go_lr(l);
        go_lr(r);
        go_lr(mc);
        for (int i=u;i<mr;i++){
            if (a[i][l-1]=='>') cnt++;
            if (a[i][l-1]=='<') cnt--;
        }
        for (int i=u;i<mr;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=l;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=l;i<=r;i++){
            if (a[mr][i]=='v') cnt--;
            if (a[mr][i]=='^') cnt++;
        }
        if (cnt > 0 || (cnt == 0 && mr > n+1)){
            d=mr-1;
            go_ud(u);
        }
        else{
            u=mr+1;
            go_ud(d);
        }
        cnt=0;
        for (int i=u;i<=d;i++){
            if (a[i][mc]=='>') cnt++;
            if (a[i][mc]=='<') cnt--;
        }
        for (int i=u;i<=d;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[d+1][i]=='v') cnt--;
            if (a[d+1][i]=='^') cnt++;
        }
        if (cnt > 0){
            l=mc+1;
        }
        else{
            r=mc-1;
        }
    }
    return 0;
}
accuracy: 0.6276595744680851
time_ms: 460
memory_kb: 33484
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=5005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
    // if ((2*n+1)*(2*n+1)<30000){
    //     char tmp='^';
    //     while (1){
    //     	tmp=ask(tmp);
    //     }
    // }
	int l=1,u=1,r=2*n+1,d=2*n+1;
    while (1){
        if (r-l+1<=2){
            go_lr(l);
            go_ud(u);
            go_ud(d);
            go_lr(r);
            go_ud(u);
        }
        if (d-u+1<=2){
            go_ud(u);
            go_lr(l);
            go_lr(r);
            go_ud(d);
            go_lr(l);
        }
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        if (mr==n+1 && mc==n+1) mc++;
        int cnt=0;
        go_ud(mr);
        go_lr(l);
        go_lr(r);
        go_lr(mc);
        for (int i=u;i<mr;i++){
            if (a[i][l-1]=='>') cnt++;
            if (a[i][l-1]=='<') cnt--;
        }
        for (int i=u;i<mr;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=l;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=l;i<=r;i++){
            if (a[mr][i]=='v') cnt--;
            if (a[mr][i]=='^') cnt++;
        }
        if (cnt > 0 || (cnt == 0 && mr > n+1)){
            d=mr-1;
            go_ud(u);
        }
        else{
            u=mr+1;
            go_ud(d);
        }
        cnt=0;
        for (int i=u;i<=d;i++){
            if (a[i][mc]=='>') cnt++;
            if (a[i][mc]=='<') cnt--;
        }
        for (int i=u;i<=d;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[d+1][i]=='v') cnt--;
            if (a[d+1][i]=='^') cnt++;
        }
        if (cnt > 0){
            l=mc+1;
        }
        else{
            r=mc-1;
        }
    }
    return 0;
}
accuracy: 0.6276595744680851
time_ms: 460
memory_kb: 33552
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=4005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
    // if ((2*n+1)*(2*n+1)<30000){
    //     char tmp='^';
    //     while (1){
    //     	tmp=ask(tmp);
    //     }
    // }
	int l=1,u=1,r=2*n+1,d=2*n+1;
    while (1){
        if (r-l+1<=2){
            go_lr(l);
            go_ud(u);
            go_ud(d);
            go_lr(r);
            go_ud(u);
        }
        if (d-u+1<=2){
            go_ud(u);
            go_lr(l);
            go_lr(r);
            go_ud(d);
            go_lr(l);
        }
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        if (mr==n+1 && mc==n+1) mc++;
        int cnt=0;
        go_ud(mr);
        go_lr(l);
        go_lr(r);
        go_lr(mc);
        for (int i=u;i<mr;i++){
            if (a[i][l-1]=='>') cnt++;
            if (a[i][l-1]=='<') cnt--;
        }
        for (int i=u;i<mr;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=l;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=l;i<=r;i++){
            if (a[mr][i]=='v') cnt--;
            if (a[mr][i]=='^') cnt++;
        }
        if (cnt > 0 || (cnt == 0 && mr > n+1)){
            d=mr-1;
            go_ud(u);
        }
        else{
            u=mr+1;
            go_ud(d);
        }
        cnt=0;
        for (int i=u;i<=d;i++){
            if (a[i][mc]=='>') cnt++;
            if (a[i][mc]=='<') cnt--;
        }
        for (int i=u;i<=d;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[d+1][i]=='v') cnt--;
            if (a[d+1][i]=='^') cnt++;
        }
        if (cnt > 0){
            l=mc+1;
        }
        else{
            r=mc-1;
        }
    }
    return 0;
}
accuracy: 0.6276595744680851
time_ms: 460
memory_kb: 33484
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=4005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc,qc;

char ask(char c){
    qc++;
    if (qc>30000) exit(1);
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
    // if ((2*n+1)*(2*n+1)<30000){
    //     char tmp='^';
    //     while (1){
    //     	tmp=ask(tmp);
    //     }
    // }
	int l=1,u=1,r=2*n+1,d=2*n+1;
    while (1){
        int mr=(u+d)/2;
        int mc=(l+r)/2;
        if (mr==n+1 && mc==n+1) mc++;
        int cnt=0;
        go_ud(mr);
        go_lr(l);
        go_lr(r);
        go_lr(mc);
        for (int i=u;i<mr;i++){
            if (a[i][l-1]=='>') cnt++;
            if (a[i][l-1]=='<') cnt--;
        }
        for (int i=u;i<mr;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=l;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=l;i<=r;i++){
            if (a[mr][i]=='v') cnt--;
            if (a[mr][i]=='^') cnt++;
        }
        if (cnt > 0 || (cnt == 0 && mr > n+1)){
            d=mr-1;
            go_ud(u);
        }
        else{
            u=mr+1;
            go_ud(d);
        }
        cnt=0;
        for (int i=u;i<=d;i++){
            if (a[i][mc]=='>') cnt++;
            if (a[i][mc]=='<') cnt--;
        }
        for (int i=u;i<=d;i++){
            if (a[i][r+1]=='>') cnt--;
            if (a[i][r+1]=='<') cnt++;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[u-1][i]=='v') cnt++;
            if (a[u-1][i]=='^') cnt--;
        }
        for (int i=mc+1;i<=r;i++){
            if (a[d+1][i]=='v') cnt--;
            if (a[d+1][i]=='^') cnt++;
        }
        if (cnt > 0){
            l=mc+1;
        }
        else{
            r=mc-1;
        }
    }
    return 0;
}
accuracy: 0.6276595744680851
time_ms: 460
memory_kb: 33488
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int N=4005;
using pi=pair<int,int>;

char a[N][N];
int n,nr,nc;

char ask(char c){
	cout << c << endl;
	cout.flush();
	char re;
	if(!(cin >> re)){
		// cout << c << "end";
		exit(0);
	}
	if (re=='G') exit(0);
	return re;
}

int go_ud (int t){
	int re=0;
	while (nr<t){
		nr++;
		char d=ask('v');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	while (nr>t){
		nr--;
		char d=ask('^');
		if (d=='>') re++;
		if (d=='<') re--;
		a[nr][nc]=d;
	}
	return re;
}

int go_lr (int t){
	int re=0;
	while (nc<t){
		nc++;
		char d=ask('>');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	while (nc>t){
		nc--;
		char d=ask('<');
		if (d=='^') re++;
		if (d=='v') re--;
		a[nr][nc]=d;
	}
	return re;
}

void rec(int u,int d,int l,int r){
	// cout << " 0: " << u << ' ' << d << ' ' << l << ' ' << r << '\n';
	int mr=(u+d)/2;
	int mc=(l+r)/2;
	int cnt=0;
	// cout << " => " << nr << ' ' << nc << ' ' << mr << ' ' << mc << '\n';
	go_ud(mr);
	go_lr(mc);
	go_lr(l);
	go_lr(r);
	go_lr(mc);
	// cout << " 1: " << u << ' ' << d << ' ' << l << ' ' << r << '\n';
	for (int i=u;i<mr;i++){
		if (a[i][l-1]=='>') cnt++;
		if (a[i][l-1]=='<') cnt--;
	}
	for (int i=u;i<mr;i++){
		if (a[i][r+1]=='>') cnt--;
		if (a[i][r+1]=='<') cnt++;
	}
	for (int i=l;i<=r;i++){
		if (a[u-1][i]=='v') cnt++;
		if (a[u-1][i]=='^') cnt--;
	}
	for (int i=l;i<=r;i++){
		if (a[mr][i]=='v') cnt--;
		if (a[mr][i]=='^') cnt++;
	}
	// cout << " => " << nr << ' ' << nc << '\n';
	if (cnt > 0 || (cnt == 0 && mr > n+1)){
		d=mr-1;
		go_ud(u);
	}
	else{
		u=mr+1;
		go_ud(d);
	}
	// cout << " 2: " << u << ' ' << d << ' ' << l << ' ' << r << '\n';
	cnt=0;
	for (int i=u;i<=d;i++){
		if (a[i][mc]=='>') cnt++;
		if (a[i][mc]=='<') cnt--;
	}
	for (int i=u;i<=d;i++){
		if (a[i][r+1]=='>') cnt--;
		if (a[i][r+1]=='<') cnt++;
	}
	for (int i=mc+1;i<=r;i++){
		if (a[u-1][i]=='v') cnt++;
		if (a[u-1][i]=='^') cnt--;
	}
	for (int i=mc+1;i<=r;i++){
		if (a[d+1][i]=='v') cnt--;
		if (a[d+1][i]=='^') cnt++;
	}
	if (cnt > 0){
		l=mc+1;
	}
	else{
		r=mc-1;
	}
	// cout << " 3: " << cnt << " = " << u << ' ' << d << ' ' << l << ' ' << r << '\n';
	// cout << "end rec\n";
	rec(u,d,l,r);
}

int main(){

    // ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i=0;i<=2*n+2;i++) {
		a[0][i]=a[2*n+2][i]=a[i][0]=a[i][2*n+2]='.';
	}
	nr=n+1, nc=n+1;
	char tmp='^';
	while (1){
		tmp=ask(tmp);
	}
	// rec(1,2*n+1,1,2*n+1);
    return 0;
}
accuracy: 1
time_ms: 460
memory_kb: 33556
final_rank: 7

code_snippet: //2列聞いてinoutの個数で左右決定、2行聞いて同様に上下決定、で繰り返せば8000+5000+5000+2500+2500+... = 28000ぐらいでいけそうな気がする
//時間、なし


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

int N;
int u,d,l,r,h,w;

char S[4444][4444];
char deb[4444][4444];

ll ask=0;

char input(){
    if(ask==29990){
        exit(0);
    }
    char c;cin>>c;
    //return deb[h][w];
    return c;
}

void U(){
    cout<<'^'<<endl;
    h--;
    
    char c=input();
    if(c=='G') exit(0);
    S[h][w]=c;
}

void D(){
    cout<<'v'<<endl;
    h++;
    
    char c=input();
    if(c=='G') exit(0);
    S[h][w]=c;
}

void L(){
    cout<<'<'<<endl;
    w--;
    
    char c=input();
    if(c=='G') exit(0);
    S[h][w]=c;
}

void R(){
    cout<<'>'<<endl;
    w++;
    
    char c=input();
    if(c=='G') exit(0);
    S[h][w]=c;
}

void GO(int th,int tw){
    while(h>th){
        U();
    }
    while(h<th){
        D();
    }
    while(w>tw){
        L();
    }
    while(w<tw){
        R();
    }
}

int main(){
    
    cin>>N;
    u=0;d=2*N+1;l=0;r=2*N+1;
    h=N;w=N;
    
    for(int i=0;i<d;i++){
        for(int j=0;j<r;j++){
            S[i][j]='.';
        }
    }
    /*
    for(int i=0;i<=2*N;i++){
        for(int j=0;j<=2*N;j++){
            cin>>deb[i][j];
        }
    }
    */
    while(d-u>10){
        {
            int a=(l+r)/2,b=a+1;
            int z=(u+d)/2;
            GO(z,a);
            GO(u,a);
            GO(u,b);
            GO(d-1,b);
            GO(d-1,a);
            GO(z,a);
            
            int cn=0;
            if(u<=N&&N<d&&l<=N&&N<=a) cn++;
            
            if(u){
                for(int j=l;j<=a;j++){
                    if(S[u-1][j]=='v') cn++;
                    if(S[u][j]=='^') cn--;
                }
            }
            if(l){
                for(int i=u;i<d;i++){
                    if(S[i][l-1]=='>') cn++;
                    if(S[i][l]=='<') cn--;
                }
            }
            if(a+1<=2*N){
                for(int i=u;i<d;i++){
                    if(S[i][a+1]=='<') cn++;
                    if(S[i][a]=='>') cn--;
                }
            }
            if(d<=2*N){
                for(int j=l;j<=a;j++){
                    if(S[d][j]=='^') cn++;
                    if(S[d-1][j]=='v') cn--;
                }
            }
            
            if(cn>=1){
                r=b;
            }else{
                l=b;
            }
        }
        
        {
            int a=(u+d)/2,b=a+1;
            int z=(l+r)/2;
            GO(a,z);
            GO(a,l);
            GO(b,l);
            GO(b,r-1);
            GO(a,r-1);
            GO(a,z);
            
            int cn=0;
            if(u<=N&&N<=a&&l<=N&&N<r) cn++;
            //if(u<=N&&N<d&&l<=N&&N<=a) cn++;
            
            if(u){
                for(int j=l;j<r;j++){
                    if(S[u-1][j]=='v') cn++;
                    if(S[u][j]=='^') cn--;
                }
            }
            if(l){
                for(int i=u;i<=a;i++){
                    if(S[i][l-1]=='>') cn++;
                    if(S[i][l]=='<') cn--;
                }
            }
            if(r<=2*N){
                for(int i=u;i<=a;i++){
                    if(S[i][r]=='<') cn++;
                    if(S[i][r-1]=='>') cn--;
                }
            }
            if(a+1<=2*N){
                for(int j=l;j<r;j++){
                    if(S[a+1][j]=='^') cn++;
                    if(S[a][j]=='v') cn--;
                }
            }
            
            if(cn>=1){
                d=b;
            }else{
                u=b;
            }
        }
    }
    
    GO(u,l);
    
    while(1){
        if(w==l){
            GO(h,r-1);
            D();
        }else{
            GO(h,l);
            D();
        }
    }
}
accuracy: 1
time_ms: 450
memory_kb: 33596
final_rank: 4