#include #include #include #include #include #include #include #include #include #include #include using namespace std; int N, M, x[40009], y[40009], ap[209][209]; int Ask (int i, int j) { int ans; printf ("%d %d\n", i, j); fflush (stdout); scanf ("%d", &ans); fflush (stdout); return ans; } int main() { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d", &N, &M);fflush (stdout); srand (time (0)); while (1) { int nr = 0; for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) if (ap[i][j] == 0) x[++nr] = i, y[nr] = j; int p = rand () % nr + 1, a = x[p], b = y[p], val; val = Ask (a, b); if (val == 0) return 0; if (val < 0) { for (int i=1; i<=a; i++) for (int j=1; j<=b; j++) ap[i][j] = 1; } else { for (int i=a; i<=N; i++) for(int j=b; j<=N; j++) ap[i][j] = 1; } } return 0; }