#include <stdio.h>
int main()
{
int t,i,n,x;
scanf("%d",&t);
for (i=1;i<=t;i++)
{
scanf("%d",&n);
for(x=1;x<=n;x++)
{
if(x%7==0)
{
printf("%d ",x);
}
else if(x%10==7)
{
printf("%d ",x);
}
else if(x/10%10==7)
{
printf("%d ",x);
}
else if(x/100%10==7)
{
printf("%d ",x);
}
else if(x/1000%10==7)
{
printf("%d ",x);
}
else if(x/10==7)
{
printf("%d ",x);
}
}
printf("\n");
}
return 0;
}
09-17
337
10-11
1377
11-04
1335