#include <iostream> #include <cstring> using namespace std; #define M 250 int a[M]; int b[M]; char a1[M]; char b1[M]; int i,la,lb; void init(); bool judge(); void output(); void outputn(); int main() { init(); int n,k; cin>>n; for(k=0;k<n;k++) { cin>>a1>>b1; la=strlen(a1);lb=strlen(b1); for(i=0; i<la; i++) a[i] = a1[la-i-1]-'0'; for(i=0; i<lb; i++) b[i] = b1[lb-i-1]-'0'; if(judge()) { for(i=0;i<la;i++) { if(a[i] < b[i]) { a[i+1]--; a[i]+=10; } a[i] = a[i] - b[i]; } output(); } else { for(i=0;i<lb;i++) { if(b[i] < a[i]) { b[i+1]--; b[i]+=10; } b[i] = b[i] - a[i]; } outputn(); } init(); } return 0; } void init() { memset(a1,NULL,sizeof(a1)); memset(b1,NULL,sizeof(b1)); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); i = la = lb = 0; } bool judge() { if(la>lb) { return 1; } else if(la<lb) { return 0; } else { for (i=0;i<la;i++) { if(a[i] > b[i]) { return 1; } else if (a[i] < b[i]) { return 0; } } if(i == la) { return 1; } } } void output() { while(!a[la-1]) { la--; if(!la) { printf("0"); break; } } for(i=la-1; i>=0; i--) printf("%d",a[i]); printf("/n"); } void outputn() { while(!b[lb-1]) { lb--; if(!lb) { printf("0"); break; } } printf("-"); for(i=lb-1;i>=0;i--) printf("%d",b[i]); printf("/n"); }