#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
int m,k,sum=0,a[17]={0,5,8,8,2,3,5,2,9,4,1,1,7,6,4,7};
cin>>m;
while(m--)
{
cin>>n;
k=n/16;
if(n%16==0)
{
cout<<7;
}
else
{
n=n%16;
cout<<a[n-1]<<" ";
}
for(int i=0;i<n;i++)
{
sum+=a[i];
}
cout<<sum+k*72<<endl;
sum=0;
}
}