The first line of the input contains an integer n (1≤n≤2×105) — the number of participants and bids.
Each of the following n lines contains two integers ai and bi ( 1≤ai≤n,1≤bi≤109,bi<bi+1 ) — the number of participant who made the i-th bid and the size of this bid.
Next line contains an integer q ( 1≤q≤2×105) — the number of question you have in mind.
Each of next qq lines contains an integer k ( 1≤k≤n), followed by k integerslj(1≤lj≤n) — the number of people who are not coming in this question and their indices. It is guarenteed that lj.
values are different for a single question.
It's guaranteed that the sum of k over all question won't exceed 2×105.
For each question print two integer — the index of the winner and the size of the winning bid. If there is no winner (there are no remaining bids at all), print two zeroes.
一场拍卖会,共n个买家。这些买家共出价n次,有的买家可能一次都没有出价。
每次出价用(ai,bi)表示,ai为此次出价人的编号,bi为价格。
出价严格递增(bi<bi+1)并且没有玩家在一轮竞拍中在没有其他竞争对手的情况下自动增加自己的出价(ai=ai+1)。
现在给定q次查询,每次去掉一些出价者及其所有出价,问最后谁是赢家并且他以什么价格赢得拍卖品。
### 输入格式
The first line of the input contains an integer $n$ ($1\le n \le 2\times10^5$) — the number of participants and bids.
Each of the following $n$ lines contains two integers $a_i$
and $b_i$
( $1\le a_i\le n$,$1\le b_{i}\le 10^{9}$,$b_{i}<b_{i+1}$ ) — the number of participant who made the $i$-th bid and the size of this bid.
Next line contains an integer $q$ ( $1\le q\le 2\times 10^5$) — the number of question you have in mind.
Each of next qq lines contains an integer $k$ ( $1\le k \le n$), followed by $k$ integers$l_{j}$($1\le l_j \le n$) — the number of people who are not coming in this question and their indices. It is guarenteed that $l_j$.
values are different for a single question.
It's guaranteed that the sum of $k$ over all question won't exceed $2\times 10^5$.
### 输出格式
For each question print two integer — the index of the winner and the size of the winning bid. If there is no winner (there are no remaining bids at all), print two zeroes.
### 题意翻译
一场拍卖会,共$n$个买家。这些买家共出价$n$次,有的买家可能一次都没有出价。
每次出价用$(a_i,b_i)$表示,$a_i$为此次出价人的编号,$b_i$为价格。
出价严格递增($b_i<b_{i+1}$)并且没有玩家在一轮竞拍中在没有其他竞争对手的情况下自动增加自己的出价($a_i \neq a_{i+1}$)。
现在给定$q$次查询,每次去掉一些出价者及其所有出价,问最后谁是赢家并且他以什么价格赢得拍卖品。