#!/usr/bin/env python3
#encoding: windows-1252

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

import sys

if __name__ == "__main__":
    linha = input()

    temp = linha.split(" ")

    m = int(temp[0])
    t = int(temp[1])

    matriz = []

    for x in range(m):
        matriz.append(input())

    for x in range(t):
        linha = input()
        temp = linha.split(" ")
        l = int(temp[0])-1;
        c = int(temp[1])-1;
        if matriz[l][c] == "A":
            print("agua")
        else:
            print("acertou");

sys.exit()