## Mock CCC '22 1 S5 - Berkeley Math Tournament Awards Ceremony

View as PDF

Points: 35 (partial)
Time limit: 0.25s
Memory limit: 1G

Problem type

Kaitlyn is the tournament director for the Berkeley Math Tournament, a tournament so large that Kaitlyn runs it on an infinite 2D plane.

The 2D plane is templatized by an rectangle , the top-left corner being and the bottom-right corner being . Square has an obstacle if and only if square in the template rectangle has an obstacle, where and are respectively remainders when and are divided by and . One can only travel directly between two squares if their Manhattan distance is 1 and both are empty.

Kaitlyn is running the awards ceremony at . She wishes to know for distinct empty points whether someone at can travel to without running into any obstacles.

#### Constraints

In tests worth 1 mark, .

#### Input Specification

The first line contains two integers, and .

The next lines contain a string of characters, each character being either . if it is empty or # if it contains an obstacle.

The next line contains one integer, .

The next lines contain two integers, and , indicating a query point .

The input is set such that each of these points and will not contain an obstacle.

#### Output Specification

Output lines. On the th line, output yes if is reachable. Otherwise, output no.

#### Sample Input 1

6 9
..#####..
..#...#..
......#..
..#####..
..#......
..#...#..
5
1 4
5 4
1 -5
5 -5
-1000000000 0

#### Sample Output 1

yes
no
no
yes
yes