The world is made up of $10$ kinds of people, those who understand binary and those who do not. These different kinds of people do not always get along so well. Bob might ask for a $10000$ ounce coffee (meaning binary) and Alice might make misinterpret his request as being in decimal and give him a $10011100010000$ ounce coffee (binary). After Sue explains that this much coffee costs $100$ dollars (decimal), Bob might assume he only has to pay $4$ dollars (interpreting the price as being in binary). In response to these differences that are difficult to resolve, these two groups have divided the world into two regions, the binary-friendly zones and the decimal-friendly zones. They have even published a map like the following to help people keep up with where the areas are (they have used ones and zeros so nobody would have trouble reading it).1111100000

1111000000

1110000011

0111100111

0011111111

Users of binary have to stay in the zones marked with a zero. Users of decimal have to stay in the zones marked with a one. You have to figure out if it is possible for either type of person to get between various locations of interest. People can move north, south, east or west, but cannot move diagonally.

-----Input-----
Input starts with a line containing two positive integers, $1 \le r \le 1000$ and $1 \le c \le 1000$. The next $r$ input lines give the contents of the map, each line containing exactly $c$ characters (which are all chosen from $0$ or $1$).

The next line has an integer $0 \le n \le 1000$. The following $n$ lines each contain one query, given as four integers: $r_1,c_1$ and $r_2,c_2$. These two pairs indicate two locations on the map, and their limits are $1 \le r_1, r_2 \le r$ and $1 \le c_1, c_2 \le c$.

-----Output-----
For each query, output binary if a binary user can start from location $r_1, c_1$ and move to location $r_2, c_2$. Output decimal if a decimal user can move between the two locations. Otherwise, output neither.

-----Examples-----
Sample Input:
1 4
1100
2
1 1 1 4
1 1 1 1
Sample Output:
neither
decimal

Source: kattis | Difficulty: MEDIUM


Solutions: