#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
struct b{
long long time;
vector<int> na;
};
int main(){
freopen("C:\\Users\\1\\Desktop\\p.txt","r",stdin);
long long n,num,t,ans=0;
cin>>n;
long long a[n];
queue<b> q;
b boat,tem;
int nation[10005];
memset(nation,0,10004);
for(int i=1;i<=n;i++){
boat.na.clear();
cin>>boat.time;
cin>>num;
for(int j=1;j<=num;j++){
cin>>t;
boat.na.push_back(t);
nation[t]++;
if(nation[t]==1)ans++;
}
q.push(boat);
tem=q.front();
while(1){
if(tem.time+86400<boat.time){
q.pop();
for(int k=0;k<tem.na.size();k++){
nation[tem.na[k]]--;
if(nation[tem.na[k]]==0) ans--;
}
tem=q.front();
}
else break;
}
a[i]=ans;
}
for(int i=1;i<=n;i++) cout<<a[i]<<endl;
return 0;
}