#pragma GCC optimize("Ofast,fast-math,unroll-loops,no-stack-protector")
#include <stdio.h>
#define N 3100<<3
char buf[N],*p1=buf,*p2=buf,buf2[N],*p3=buf2,*p4=buf2,c;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,N,stdin),p1==p2)?EOF:*p1++)
void inline pc
(char i
){if(p3
==p4
){puts(buf2
);p3
=buf2
;}*p3
++=i
;} int n,k,j;
int main(){
p4+=N;
for(;(c=gc())!=EOF;){
for(n=0;c!='\n';n+=c-'0',c=gc())n*=10;
if(n==1){pc('0');c=gc();}
else{
while(--n){
for(k=0;c=gc(),c!=' ';k+=c-'0')k*=10;
k*=n;for(j=10;j<=k;)j*=10;
for(j/=10;j;k%=j,j/=10)pc((k/j)+'0');
pc(' ');
}
}
for(;c!='\n'&&c!=EOF;)c=gc();pc('\n');
}
return 0;
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0LGZhc3QtbWF0aCx1bnJvbGwtbG9vcHMsbm8tc3RhY2stcHJvdGVjdG9yIikKI2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgTiAzMTAwPDwzCmNoYXIgYnVmW05dLCpwMT1idWYsKnAyPWJ1ZixidWYyW05dLCpwMz1idWYyLCpwND1idWYyLGM7CiNkZWZpbmUgZ2MoKSAocDE9PXAyJiYocDI9KHAxPWJ1ZikrZnJlYWQoYnVmLDEsTixzdGRpbikscDE9PXAyKT9FT0Y6KnAxKyspCnZvaWQgaW5saW5lIHBjKGNoYXIgaSl7aWYocDM9PXA0KXtwdXRzKGJ1ZjIpO3AzPWJ1ZjI7fSpwMysrPWk7fQppbnQgbixrLGo7CmludCBtYWluKCl7CiBwNCs9TjsKIGZvcig7KGM9Z2MoKSkhPUVPRjspewogIGZvcihuPTA7YyE9J1xuJztuKz1jLScwJyxjPWdjKCkpbio9MTA7CiAgaWYobj09MSl7cGMoJzAnKTtjPWdjKCk7fQogIGVsc2V7CiAgIHdoaWxlKC0tbil7CiAgICBmb3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