#include <bits/stdc++.h>
using namespace std;
struct Passager{
int time0;
int country0;
};
queue <Passager> Q;
int Country[300000], ans[300000], pass[300000], n;
int main(){
cin >> n;
int cnt = 0;
int t, k;
for (int i = 1; i <= n; i++){
cin >> t >> k;
while(!Q.empty() && Q.front().time0 + 86400 < t){
Country[Q.front().country0]--;
if (Country[Q.front().country0] == 0) cnt--;
Q.pop();
}
for (int j = 1; j <= k; j++){
cin >> pass[j];
if (Country[pass[j]] == 0) cnt++;
Country[pass[j]]++;
Passager tmp;
tmp.time0 = t;
tmp.country0 = pass[j];
Q.push(tmp);
}
ans[i] = cnt;
}
for (int i = 1; i <= n; i++)
cout << ans[i] << endl;
return 0;
}