{"problem":{"name":"Permutation Grid","description":{"content":"Given are two permutations of $1,\\dots,n$: $R_1,\\dots,R_n$ and $C_1,\\dots,C_n$. We have a grid with $n$ horizontal rows and $n$ vertical columns. You will paint each square black or white to satisfy t","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc132_a"},"statements":[{"statement_type":"Markdown","content":"Given are two permutations of $1,\\dots,n$: $R_1,\\dots,R_n$ and $C_1,\\dots,C_n$.\nWe have a grid with $n$ horizontal rows and $n$ vertical columns. You will paint each square black or white to satisfy the following conditions.\n\n*   For each $i=1,\\dots,n$, the $i$\\-th row from the top has exactly $R_i$ black squares.\n*   For each $j=1,\\dots,n$, the $j$\\-th column from the left has exactly $C_j$ black squares.\n\nIt can be proved that, under the Constraints of this problem, there is exactly one way to paint the grid to satisfy the conditions.\nYou are given $q$ queries $(r_1,c_1),\\dots,(r_q,c_q)$. For each $i=1,\\dots,q$, print `#` if the square at the $r_i$\\-th row from the top and $c_i$\\-th column from the left is painted black; print `.` if that square is painted white.\n\n## Constraints\n\n*   $1\\le n,q\\le 10^5$\n*   $R_1,\\dots,R_n$ and $C_1,\\dots,C_n$ are each permutations of $1,\\dots,n$.\n*   $1\\le r_i,c_i \\le n$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$n$\n$R_1$ $\\dots$ $R_n$\n$C_1$ $\\dots$ $C_n$\n$q$\n$r_1$ $c_1$\n$\\vdots$\n$r_q$ $c_q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc132_a","tags":[],"sample_group":[["5\n5 2 3 4 1\n4 2 3 1 5\n7\n1 5\n5 1\n1 1\n2 2\n3 3\n4 4\n5 5","#.#.#.#\n\nThe conditions are satisfied by painting the grid as follows.\n\n#####\n#...#\n#.#.#\n###.#\n....#"]],"created_at":"2026-03-03 11:01:14"}}