#include<cstdio>
#include<iostream>
#include<cstring>
#define ref(i,x,y)for(int i=x;i<=y;i++)
#define def(i,x,y)for(int i=x;i>=y;i--)
using namespace std;
int lena,lenb,lenc,p,t,a[1010],b[1010],c[1010];
char a1[1010];
bool flag=0;
int main()
{
scanf("%d",&t);
while(t--){
memset(a1,0,sizeof a1);
memset(a,0,sizeof a);
memset(b,0,sizeof b);
memset(c,0,sizeof c);
scanf("%s",a1);
lena=strlen(a1);lenb=1;
lenc=max(lena,lenb);b[1]=1;
if(a1[0]==‘-‘&&a1[1]==‘1‘&&a1[2]==‘\0‘){printf("0 ");continue;}
if(a1[0]==‘-‘){
flag=1;
def(i,lena-1,1) a[++p]=a1[i]-48;
lena--;p=0;
}
else
ref(i,0,lena-1) a[lena-i]=a1[i]-48;
if(!flag){
ref(i,1,lenc){
c[i]+=a[i]+b[i];
c[i+1]+=c[i]/10;
c[i]%=10;
}
int j=lenc+1;
while(c[j]==0&&j>1) j--;
def(i,j,1) printf("%d",c[i]);
printf(" ");
}
else{
printf("-");flag=0;
ref(i,1,lena){
if(a[i]<b[i]){
a[i+1]--;a[i]+=10;
}
c[i]=a[i]-b[i];
}
int j=lena+1;
while(c[j]==0&&j>1) j--;
def(i,j,1) printf("%d",c[i]);
printf(" ");
}
}
return 0;
}