rt
#include<bits/stdc++.h>
using namespace std;
int T,n,ans,k,a[300010];
long long t;
struct node{
long long t,num;
};
queue<node> q;
signed main()
{
cin>>T;
while (T--)
{
cin>>t>>n;
for (int i=1;i<=n;i++)
{
cin>>k;
q.push(node{k,t});
a[k]++;
if (a[k]==1) ans++;
}//input
while (!q.empty())
{
node x=q.front();
if (t>=x.t+86400)
{
a[x.num]--;
if (!a[x.num]) ans--;
q.pop();
}
else break;
}//check
cout<<ans<<endl;
}
}