Advertisement Matching

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

MOLOCO is a company that matches advertisers with potential users using their high-performance ad platform.

MOLOCO is in contact with NN advertisers, where the ii-th advertiser has paid for a_ia\_i advertisements to deliver. Our advanced prediction algorithm has picked MM potential recipients, which we will deliver the advertisements to. For the jj-th recipient, we can deliver up to b_jb\_j advertisements. 

Jaehyun is testing several hypotheses to increase engagement in the advertisements. One day, Jaehyun thought that all advertisements received by a single recipient should come from different advertisers: it is boring to watch the same advertisement multiple times. 

Jaehyun wants to estimate the profitability of his hypotheses. He will perform the following kinds of updates.

  • 1 i: Increase a_ia\_i by one.
  • 2 i: Decrease a_ia\_i by one.
  • 3 j: Increase b_jb\_j by one.
  • 4 j: Decrease b_jb\_j by one.

All updates are cumulative. Jaehyun wants to check if the system can deliver all advertisements of our advertisers given the changing landscape of the advertisers and recipients.

입력

The first line contains two integers, NN and MM (1N,M250,0001 \le N, M \le 250\\,000).

The next line contains NN integers a_1,a_2,,a_Na\_1, a\_2, \ldots, a\_N (0a_i250,0000 \le a\_i \le 250\\,000).

The next line contains MM integers b_1,b_2,,b_Mb\_1, b\_2, \ldots, b\_M (0b_j250,0000 \le b\_j \le 250\\,000).

The next line contains a single integer QQ (1Q250,0001 \le Q \le 250\\,000).

The next QQ lines contain two integers in one of the following forms:

  • 1 i (1iN1 \le i \le N)
  • 2 i (1iN1 \le i \le N)
  • 3 j (1jM1 \le j \le M)
  • 4 j (1jM1 \le j \le M)

The input will be set in a way such that all a_ia\_i and b_jb\_j values are always nonnegative.

출력

Print QQ lines. On the ii-th line, print 11 if all advertisements can be delivered given the first ii updates, and 00 otherwise.