Kozik keeps an aquarium of African fish. Each fish has a mass and an age, and every day it must satisfy its hunger by eating one other, smaller fish; a fish that cannot eat dies at the end of that day.
Each day the fish act one at a time. The hungry fish with the greatest mass acts first; if several fish share the greatest mass, the oldest of them acts first. The acting fish devours the smallest fish currently in the aquarium; if several fish share the smallest mass, the youngest of them is eaten. When a fish devours another, its mass grows by half of the eaten fish's mass, and it is no longer hungry that day. If, when it is a fish's turn, no smaller fish is left to eat, that fish starves and dies at the end of the day.
Fish are compared first by mass, and for equal masses the younger fish counts as smaller. All ages are distinct, so this order is total, while masses may repeat. A fish can only devour a fish that is smaller than itself under this order.
For a chosen fish r and a number of days x, decide whether fish r is still alive after x days, where x=0 means right now.
The first line contains an integer n (1≤n≤106), the number of fish.
Each of the next n lines contains two integers mi and wi (1≤mi,wi≤109), the mass and the age of the i-th fish.
The next line contains an integer z (1≤z≤106), the number of queries.
Each of the next z lines contains two integers rk and xk (1≤rk≤n, 0≤xk≤109), asking whether fish rk is still alive after xk days.
For each query, print TAK if fish rk is still alive after xk days, or NIE otherwise. Here TAK means yes and NIE means no. Print one answer per line, in the order of the queries.