#arc132a. [arc132_a]Permutation Grid

[arc132_a]Permutation Grid

Problem Statement

Given are two permutations of 1,dots,n1,\\dots,n: R1,dots,RnR_1,\\dots,R_n and C1,dots,CnC_1,\\dots,C_n.

We have a grid with nn horizontal rows and nn vertical columns. You will paint each square black or white to satisfy the following conditions.

  • For each i=1,dots,ni=1,\\dots,n, the ii-th row from the top has exactly RiR_i black squares.
  • For each j=1,dots,nj=1,\\dots,n, the jj-th column from the left has exactly CjC_j black squares.

It can be proved that, under the Constraints of this problem, there is exactly one way to paint the grid to satisfy the conditions.

You are given qq queries (r1,c1),dots,(rq,cq)(r_1,c_1),\\dots,(r_q,c_q). For each i=1,dots,qi=1,\\dots,q, print # if the square at the rir_i-th row from the top and cic_i-th column from the left is painted black; print . if that square is painted white.

Constraints

  • 1len,qle1051\\le n,q\\le 10^5
  • R1,dots,RnR_1,\\dots,R_n and C1,dots,CnC_1,\\dots,C_n are each permutations of 1,dots,n1,\\dots,n.
  • 1leri,cilen1\\le r_i,c_i \\le n
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

nn R1R_1 dots\\dots RnR_n C1C_1 dots\\dots CnC_n qq r1r_1 c1c_1 vdots\\vdots rqr_q cqc_q

Output

Print a string of length qq whose ii-th character is the answer to the ii-th query.


Sample Input 1

5
5 2 3 4 1
4 2 3 1 5
7
1 5
5 1
1 1
2 2
3 3
4 4
5 5

Sample Output 1

#.#.#.#

The conditions are satisfied by painting the grid as follows.

#####
#...#
#.#.#
###.#
....#