package maratonacps2020;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Prof. Henrique Louro
 */
public class Naval {

    public static void main(String[] args) throws IOException {

        String linha;

        BufferedReader entrada;

        entrada = new BufferedReader(new InputStreamReader(System.in));

        linha = entrada.readLine();

        String temp[] = linha.split(" ");

        int m = Integer.parseInt(temp[0]);
        int t = Integer.parseInt(temp[1]);

        String matriz[] = new String[m];

        for (int x = 0; x < m; x++) {
            matriz[x] = entrada.readLine();
        }

        int l, c;

        for (int x = 0; x < t; x++) {
            linha = entrada.readLine();
            temp = linha.split(" ");
            l = Integer.parseInt(temp[0])-1;
            c = Integer.parseInt(temp[1])-1;
            if (matriz[l].charAt(c) == 'A') {
                System.out.println("agua");
            } else {
                System.out.println("acertou");
            }
        }
    }
}
