#include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e6 + 10; char g[105][105]; int dx, dy, n, m; string feedback = "", last = ""; string solve(int x, int y) { if (feedback == "") { return "LEFT"; } if (feedback == "N") { dx = -1; dy = 0; } if (feedback == "W") { dx = 0; dy = -1; } if (feedback == "S") { dx = 1; dy = 0; } if (feedback == "E") { dx = 0; dy = -1; } if ((feedback == "N" || feedback == "S" || feedback == "W" || feedback == "E") && last == "") { return "GO"; } else if (feedback == "FAIL" && last == "N") { g[x - 1][y] = '#'; return "LEFT"; } else if (feedback == "FAIL" && last == "E") { g[x][y + 1] = '#'; return "LEFT"; } else if (feedback == "FAIL" && last == "W") { g[x][y - 1] = '#'; return "LEFT"; } else if (feedback == "FAIL" && last == "S") { g[x + 1][y] = '#'; return "LEFT"; } else if (feedback == "SUCC") { g[x + dx][y + dy] = '.'; return "GO"; } } bool all_explored(int x, int y) { if (g[x][y + 1] != '$' && g[x][y - 1] != '$' && g[x + 1][y] != '$' && g[x - 1][y] != '$') return 1; else return 0; } int main() { int x = 50, y = 50, times = 0; memset(g, '$', sizeof(g)); while (1) { times++; if (times == 1) cout << "LEFT\n"; else cout << solve(x, y) << '\n'; cin >> feedback; if (all_explored(x, y)) { cout << "END" << '\n'; cout << n << " " << m; for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 100; j++) { if (g[i][j] != '$') cout << g[i][j]; } cout << '\n'; } } } return 0; }