Hoax Spreading

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

문제

Pak Dengklek has just developed a social media site. There are NN users using the site, numbered 00 to N1N - 1. There are SS hours in one day. All of these users have a fixed usage schedule from day to day. For each ii such that 0iN10 ≤ i ≤ N - 1, user ii will be online T\[i]T\[i] times every day:

  • from the start of the A\[i]\[0]A\[i]\[0]th hour to the end of the B\[i]\[0]B\[i]\[0]th hour,
  • from the start of the A\[i]\[1]A\[i]\[1]th hour to the end of the B\[i]\[1]B\[i]\[1]th hour
  • ...
  • and from the start of the A\[i]\[T\[i]1]A\[i]\[T\[i] - 1]th hour to the end of the B\[i]\[T\[i]1]B\[i]\[T\[i] - 1]th hour.

At any time, all users on the site like to share news to all other online users. Unfortunately, one of the NN users has a hoax at the start of the first day and will spread it. Hence, all users who meet the user with the hoax will also have the hoax at the end of the first day. Two users are stated to be met if there is at least an hour where the two users are both online.

This hoax will also be spread on the second day. Therefore, all users who meet the user with the hoax at the end of the first day will also have the hoax at the end of the second day. This continued the following days.

There are QQ scenarios, each can be represented as an integer PP. For each scenario, the user who has the hoax at the start of the first day is user PP. A different scenario might cause a different hoax spreading. Therefore, for each scenario, Pak Dengklek wonders on the number of users with the hoax at the end of the NNth day, where NN is the number of users.

제한

  • 1N200,0001 ≤ N ≤ 200\\,000
  • 1S109 1 ≤ S ≤ 10^9
  • 1Q100,000 1 ≤ Q ≤ 100\\,000
  • 1T\[i]S 1 ≤ T\[i] ≤ S (for each ii such that 0iN10 ≤ i ≤ N - 1)
  • The sum of all elements of TT does not exceed 200,000200\\,000.
  • 1A\[i]\[j]B\[i]\[j]S1 ≤ A\[i]\[j] ≤ B\[i]\[j] ≤ S (for each ii and jj such that 0iN10 ≤ i ≤ N - 1 and 0jT\[i]10 ≤ j ≤ T\[i] - 1)
  • B\[i]\[j1]<A\[i]\[j]B\[i]\[j - 1] < A\[i]\[j] (for each ii and jj such that 0iN10 ≤ i ≤ N - 1 and 1jT\[i]11 ≤ j ≤ T\[i] - 1)
  • 0PN10 ≤ P ≤ N - 1
  • The values of PP among all scenarios are pairwise distinct.