#t439. 海港

海港

The Harbor

Problem Description

Little K is a customs officer at a harbor. Every day many ships arrive at the harbor, usually carrying passengers from many different countries.

Little K is very interested in the ships arriving at the harbor, and he records the situation of each ship arriving at the harbor by time: for the ii-th arriving ship, he records its arrival time tit_i (in seconds), the number of passengers kik_i on board, and the nationality xi,1,xi,2,…,xi,kx_{i,1}, x_{i,2},\dots,x_{i,k} of each passenger.

Little K has recorded information about nn ships, and he hopes you can help calculate, for each ship's arrival time, how many different countries the passengers who arrived by ship within the past 2424 hours (2424 hours =86400=86400 seconds) come from.

Formally, you need to compute nn pieces of information. For the ii-th piece of output information, you need to count the ships pp satisfying ti−86400<tp≤tit_i-86400<t_p\le t_i, and among all xp,jx_{p,j}, how many different numbers there are in total.

Input Format

The first line contains a positive integer nn, indicating that Little K recorded information about nn ships.

The following nn lines each describe one ship: the first two integers tit_i and kik_i represent the arrival time of the ship and the number of passengers on board, and the following kik_i integers xi,jx_{i,j} represent the nationalities of the passengers on board.

It is guaranteed that the input tit_i is increasing, in seconds; starting from when Little K first starts work, this ship arrives at the tit_i-th second.

It is guaranteed that 1≤n≤1051\le n\le 10^5, ∑ki≤3×105\sum k_i\le 3\times 10^5, 1≤xi,j≤1051\le x_{i,j}\le 10^5, 1≤ti−1≤ti≤1091\le t_{i-1}\le t_i\le 10^9.

Here ∑ki\sum k_i denotes the sum of all kik_i.

Output Format

Output nn lines; the ii-th line outputs an integer representing the statistical information after the ii-th ship arrives.

Sample Input 1

3
1 4 4 1 2 2
2 2 2 3
10 1 3

Sample Output 1

3
4
4

Sample Input 2

4
1 4 1 2 2 3
3 2 2 3
86401 2 3 4
86402 1 5

Sample Output 2

3
3
3
4

Sample Explanation 1

  • The first ship arrives at the 11st second. The ships arriving in the last 2424 hours is the first ship, with 44 passengers from countries 4,1,2,24,1,2,2, coming from 33 different countries in total.
  • The second ship arrives at the 22nd second. The ships arriving in the last 2424 hours are the first and second ships, with 4+2=64+2=6 passengers from countries 4,1,2,2,2,34,1,2,2,2,3, coming from 44 different countries in total.
  • The third ship arrives at the 1010th second. The ships arriving in the last 2424 hours are the first, second, and third ships, with 4+2+1=74+2+1=7 passengers from countries 4,1,2,2,2,3,34,1,2,2,2,3,3, coming from 44 different countries in total.

Sample Explanation 2

  • The first ship arrives at the 11st second. The ships arriving in the last 2424 hours is the first ship, with 44 passengers from countries 1,2,2,31,2,2,3, coming from 33 different countries in total.
  • The second ship arrives at the 33rd second. The ships arriving in the last 2424 hours are the first and second ships, with 4+2=64+2=6 passengers from countries 1,2,2,3,2,31,2,2,3,2,3, coming from 33 different countries in total.
  • The third ship arrives at the 8640186401-th second. The ships arriving in the last 2424 hours are the second and third ships, with 2+2=42+2=4 passengers from countries 2,3,3,42,3,3,4, coming from 33 different countries in total.
  • The fourth ship arrives at the 8640286402-th second. The ships arriving in the last 2424 hours are the second, third, and fourth ships, with 2+2+1=52+2+1=5 passengers from countries 2,3,3,4,52,3,3,4,5, coming from 44 different countries in total.

Constraints

  • For 10%10\% of the test points, n=1n=1, ∑ki≤10\sum k_i\le 10, 1≤xi,j≤101\le x_{i,j}\le 10, 1≤ti≤101\le t_i\le 10.
  • For 20%20\% of the test points, 1≤n≤101\le n\le 10, ∑ki≤100\sum k_i\le 100, 1≤xi,j≤1001\le x_{i,j}\le 100, 1≤ti≤327671\le t_i\le 32767.
  • For 40%40\% of the test points, 1≤n≤1001\le n\le 100, ∑ki≤100\sum k_i\le 100, 1≤xi,j≤1001\le x_{i,j}\le 100, 1≤ti≤864001\le t_i\le 86400.
  • For 70%70\% of the test points, 1≤n≤10001\le n\le 1000, ∑ki≤3000\sum k_i\le 3000, 1≤xi,j≤10001\le x_{i,j}\le 1000, 1≤ti≤1091\le t_i\le 10^9.
  • For 100%100\% of the test points, 1≤n≤1051\le n\le 10^5, ∑ki≤3×105\sum k_i\le 3\times 10^5, 1≤xi,j≤1051\le x_{i,j}\le 10^5, 1≤ti≤1091\le t_i\le 10^9.