#include<bits/stdc++.h> using namespace std; char a[90][90]; int x, y, d; bool vis[90][90]; string feedback; void go() { if (dir == 0) x--; else if (dir == 1) y++; else if (dir == 2) x++; else y--; } bool check(int x, int y) { if (x < 1 || y < 1 || x > 80 || y > 80 || vis[x][y] || a[x][y] == '#') return 0; if (a[x][y] == '?') return 1; return check(x - 1, y) || check(x + 1, y) || check(x, y - 1) || check(x, y + 1); } void solve() { while (1) { cout << "LEFT"; cin >> feedback; if (feedback == "N") dir = 0; else if (feedback == "E") dir = 1; else if (feedback == "S") dir = 2; else dir = 3; int a = x, b = y; go(); if (a[x][y] == '#') { x = a, y = b; continue; } x = a, y = b; cout << "GO"; cin >> feedback; if (feedback == "FAIL") { int a = x, b = y; go(); a[x][y] == '#'; x = a, y = b; return; } else go(), a[x][y] = '.'; memset(vis, 0, sizeof vis); if (!check(x, y)) { cout << "END\n" << x << " " << y << "\n"; for (int i = 1; i <= 80; i++) { for (int j = 1; j <= 80; j++) cout << a[x][y]; cout << "\n"; } return 0; } } } int main() { for (int i = 1; i <= 200; i++) { for (int j = 1; j <= 200; j++) a[i][j] = '?'; } x = y = 40; a[x][y] = '.'; solve(); }