#include <bits/stdc++.h>
using namespace std;
#define REP(i,j,k) for(int i = j ; i < k ; ++i)
#define MEM(i,j) memset(i , j , sizeof (i))
const int sum = 72; // the sum of mod
int mod[16] = {7,0,5,8,8,2,3,5,2,9,4,1,1,7,6,4};
int dp[16]; //mod add up
void init(){
MEM(dp, 0);
REP(k,1,16){
dp[k] += dp[k - 1] + mod[k];
}
}
int main(){
// 1 / 17 == 0.05288235294117647 circulate
int m, n;
init();
scanf("%d", &m);
REP(i, 0, m){
scanf("%d", &n);
printf("%d %d\n", mod[n%16], sum*(n/16)+dp[n%16]);
}
return 0;
}