# include <stdio.h>
# include <string>
# include <iostream>
# include <cstdio>
# include <cstdlib>
# include <string>
# include <vector>

using namespace std;

vector<string> split(string& s, const char& c) {
    string buffer{ "" };

    vector<string> resultado;

    for (char caractere : s) {
        if (caractere != c) {
            buffer += caractere;
        }
        else {
            resultado.push_back(buffer);
            buffer = "";
        }
    }
    if (buffer != "")
        resultado.push_back(buffer);

    return resultado;
}

int main() {

    string linha;
    int M;
    int T;

    while (true)
    {
        getline(cin, linha);
        if (linha == "0")
        {
            break;
        }

        vector<string> temp = split(linha, ' ');
        
        M = atoi(temp[0].c_str());
        T = atoi(temp[1].c_str());

        char Mapa[100][100];

        for(int i = 0; i < M; i++) {
            getline(cin, linha);
            for (int z = 0; z < M; z++)
                Mapa[i][z] = linha[z];
        }

        for (int j = 0; j < T; j++)
        {
            getline(cin, linha);
            vector<string> temp = split(linha, ' ');
            if (Mapa[atoi(temp[0].c_str()) - 1][atoi(temp[1].c_str()) - 1] == 'X') {
                cout << "acertou\n";
            }
            else
                cout << "agua\n";
        }

        break;

    }
    return 0;
}