#include<bits/stdc++.h>
using namespace std;
int getans(int n,int x){
char xx=x+'0';
int ans=0;
for(int i=1;i<=n;++i){
stringstream ss;
ss<<i;
string s;
ss>>s;
//cout<<"*"<<s<<"*"<<endl;
for(int j=0;j<s.size();++j){
if(s[j]==xx){
//cout<<endl<<"*"<<i<<"*"<<endl;
++ans;
//cout<<" "<<ans;
}
}
}
return ans;
}
main(){
int t;
int n;
cin>>t;
while(t--){
cin>>n;
int a[10];
for(int i=0;i<10;++i){
a[i]=getans(n,i);
cout<<a[i]<<" ";
}
cout<<endl;
}
}