贪心
#include<bits/stdc++.h>
using namespace std;int tub[200];
int book[101];
int main()
{
int t;
cin>>t;
while(t--)
{
int n,k;cin>>n>>k;
memset(tub,0,sizeof(tub));
memset(book,0,sizeof(book));
for(int i=0;i<n;i++) cin>>tub[i];
sort(tub,tub+n);
for(int i=1;i<=n;i++)
{
int flag=1;
for(int j=0;flag&&j<101;j++)
{
if(book[j]==0)
{
if(tub[j]==i)
{
book[j]=1;
flag--;
}
if(tub[j]<i&&!book[j])
{
if((i-tub[j])%k==0)
{
book[j]=1;
flag--;
}
}
}
}
}
int judge=1;
for(int i=0;i<n;i++) if(book[i]==0) judge=0;
if(judge) cout<<"Jerry"<<endl;
else cout<<"Tom"<<endl;
}
return 0;
}