#include<iostream>using namespace std;int main(){int i,m,n,d;int sum[170001]={0};d=1;for(int i=1; i<=170001; i++){d*=10;sum[i]=sum[i-1]+d/17;d%=17;}cin>>m;for(i=1; i<=m; i++){cin>>n;printf("%d %d\n",sum[n]-sum[n-1],sum[n]);}}