description: Tanya is learning how to add numbers, but so far she is not doing it correctly. She is adding two numbers a and b using the following algorithm:
  
    1. If one of the numbers is shorter than the other, Tanya adds leading zeros so that the numbers are the same length. 
    2. The numbers are processed from right to left (that is, from the least significant digits to the most significant). 
    3. In the first step, she adds the last digit of a to the last digit of b and writes their sum in the answer. 
    4. At each next step, she performs the same operation on each pair of digits in the same place and writes the result to the left side of the answer. 
  
  
  
  For example, the numbers a = 17236 and b = 3465 Tanya adds up as follows:
  
  $$$ \large{ \begin{array}{r} + \begin{array}{r} 17236\\\ 03465\\\ \end{array} \\\ \hline \begin{array}{r} 1106911 \end{array} \end{array}} $$$
  
    * calculates the sum of 6 + 5 = 11 and writes 11 in the answer. 
    * calculates the sum of 3 + 6 = 9 and writes the result to the left side of the answer to get 911. 
    * calculates the sum of 2 + 4 = 6 and writes the result to the left side of the answer to get 6911. 
    * calculates the sum of 7 + 3 = 10, and writes the result to the left side of the answer to get 106911. 
    * calculates the sum of 1 + 0 = 1 and writes the result to the left side of the answer and get 1106911. 
  
  
  
  As a result, she gets 1106911.
  
  You are given two positive integers a and s. Find the number b such that by adding a and b as described above, Tanya will get s. Or determine that no suitable b exists.
  
  Input
  
  The first line of input data contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases.
  
  Each test case consists of a single line containing two positive integers a and s (1 ≤ a < s ≤ 10^{18}) separated by a space.
  
  Output
  
  For each test case print the answer on a separate line.
  
  If the solution exists, print a single positive integer b. The answer must be written without leading zeros. If multiple answers exist, print any of them.
  
  If no suitable number b exists, output -1.
  
  Example
  
  Input
  
  
  6
  17236 1106911
  1 5
  108 112
  12345 1023412
  1 11
  1 20
  
  
  Output
  
  
  3465
  4
  -1
  90007
  10
  -1
  
  Note
  
  The first test case is explained in the main part of the statement.
  
  In the third test case, we cannot choose b that satisfies the problem statement.
solution: 
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.util.*;
  import java.util.concurrent.ThreadLocalRandom;
  
  
  
  public class a729 {
  
  	public static void main(String[] args) throws IOException {
     
  //		try {
  			
  //			System.out.println(printDivisors(1));
  			
  		BufferedWriter out = new BufferedWriter(
  	            new OutputStreamWriter(System.out));
  		BufferedReader br = new BufferedReader(
  		        new InputStreamReader(System.in));
  		PrintWriter pt = new PrintWriter(System.out);
  		FastReader sc = new FastReader();
  
  		int t = sc.nextInt();
  //		int t = Integer.parseInt(br.readLine());
  	
  for(int o = 0 ; o<t;o++){
  	
  String s1 = sc.next();
  String s2 = sc.next();
  String ans = "";
  StringBuilder sb1 = new StringBuilder("");
  //StringBuilder sb2 = new StringBuilder(s2);
  //Integer.parseInt(sb1);
  int n = s1.length();
  int m = s2.length();
  if(m<n) {
  	System.out.println(-1);
  	continue;
  }
  int i = n-1;
  int j = m-1;
  int f = 0;
  while(i>=0 && j>=0) {
  	if(s2.charAt(j)>=s1.charAt(i)) {
  		int x = (int)s2.charAt(j)-(int)s1.charAt(i);
  		ans = x + ans;
  	i--;
  	j--;
  	}else{
  		if(j <= 0) {
  //			System.out.println(br);
  		    j--;
  			f = 1;
  		break;
  		}
  		int a = Integer.parseInt(s2.substring(j-1,j+1));
  		int b = s1.charAt(i)-'0';
  	int x = a-b;
  	if(x>9) {
  		f = 1;
  		break;
  	}
  	if(x<0) {
  		f = 1;
  		break;
  	}
  	ans = x + ans;
  	i--;
  	j-=2;
  	}
  	
  	
  }
  if(i>=0 && j<0) {
  	System.out.println(-1);
  	continue;
  }
  if(j>-2)
  ans = s2.substring(0,j+1) + ans;
  
  if(f == 1) {
  	System.out.println(-1);
  continue;
  }else {
  	
  	System.out.println(Long.parseLong(ans));
  	
  
  }
  }
  //     }catch(Exception e) {
  //    	 return;
  //     }
       }
       
       
  //------------------------------------------------------------------------------------------------------------------------------------------------
  	
  	static int printDivisors(int n)
      {
          int cnt = 0;
  		for (int i=1; i<=Math.sqrt(n); i++)
          {
              if (n%i==0)
              {
                  if (n/i == i)
                  	cnt++;
                  	
                  else 
                  	cnt+=2;
              }
          }
      
      return cnt;
      }
  	
  	
  	public static StringBuilder comp(long n) {
  		StringBuilder x = new StringBuilder("");
  		for(int i = 0 ; i<n;i++) {
  			x.append('b');
  		}
  		return x;
  	}
  	
  	
  	public static long findgcd(long[] arr,int v) {
  		int n = arr.length;
  		long g = arr[v];
  		for(int i = v ; i<n;i+=2) {
  			g = gcd(g, arr[i]);
  		}
  		return g;
  	}
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	public static int count(long x) {
  		int a = 0;
  		while(x>0) {
  			x/=2;
  			a++;
  		}
  		return a;
  		
  	}
  	
  
  	public static long ncr(long[] fac, int n , int r , long m) {
  		return fac[n]*(modInverse(fac[r], m))%m *(modInverse(fac[n-r], m))%m; 
  	}
  	
  	
  	public static void build(int [][] seg,char []arr,int idx, int lo , int hi) {
  	if(lo == hi) {
  //		seg[idx] = arr[lo];
  		seg[idx][(int)arr[lo]-'a'] = 1;
  		
  		return;
  	}
  	int mid = (lo + hi)/2;
  build(seg,arr,2*idx+1, lo, mid);
  build(seg,arr,idx*2+2, mid +1, hi);
  //seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  for(int i = 0 ; i<27;i++) {
  	seg[idx][i] = seg[2*idx+1][i] + seg[2*idx + 2][i];
  }
  	}
  //for f/inding minimum in range 
  public static void query(int[][]seg,int[]ans,int idx , int lo , int hi , int l , int r) {
  	if(lo>=l && hi<=r) {
  		for(int i = 0 ; i<27;i++) {
  			ans[i]+= seg[idx][i];
  		}
  		return ;
  	}
  if(hi<l || lo>r) {
  	return;
  }
  int mid = (lo + hi)/2;
  query(seg,ans,idx*2 +1, lo, mid, l, r);
  query(seg,ans,idx*2 + 2, mid + 1, hi, l, r);
  //return Math.min(left, right);
  }
  //// for sum
  //
  public static void update(int[][]seg,char[]arr,int idx, int lo , int hi , int node , char val) {
  if(lo == hi) {
  //	seg[idx] += val;
  seg[idx][val-'a']++;
  seg[idx][arr[node]-'a']--;
  
  }else {
  int mid = (lo + hi )/2;
  if(node<=mid && node>=lo) {
  update(seg,arr, idx * 2 +1, lo, mid, node, val);
  }else {
  update(seg,arr, idx*2 + 2, mid + 1, hi, node, val);
  }
  //seg[idx] = seg[idx*2 + 1] + seg[idx*2 + 2];
  for(int i = 0 ; i<27;i++) {
  	seg[idx][i] = seg[2*idx+1][i] + seg[2*idx + 2][i];
  }
  }
  
  }
  	
  	
  	
  	
  	
  	
  	public static int lower_bound(int array[], int low, int high, int key){
  	// Base Case
  	if (low > high) {
  	return low;
  	}
  
  	// Find the middle index
  	int mid = low + (high - low) / 2;
  
  	// If key is lesser than or equal to
  	// array[mid] , then search
  	// in left subarray
  	if (key <= array[mid]) {
  
  	return lower_bound(array, low,
  	            mid - 1, key);
  	}
  
  	// If key is greater than array[mid],
  	// then find in right subarray
  	return lower_bound(array, mid + 1, high,
  	        key);
  	}
  	
  	public static int upper_bound(int arr[], int low,
              int high, int key){
  // Base Case
  if (low > high || low == arr.length)
  return low;
  
  // Find the value of middle index
  int mid = low + (high - low) / 2;
  
  // If key is greater than or equal
  // to array[mid], then find in
  // right subarray
  if (key >= arr[mid]) {
  return upper_bound(arr, mid + 1, high,
                  key);
  }
  
  // If key is less than array[mid],
  // then find in left subarray
  return upper_bound(arr, low, mid - 1,
              key);
  }
  
  //	-----------------------------------------------------------------------------------------------------------------------------------------------
  	public static long gcd(long a, long b){
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  //--------------------------------------------------------------------------------------------------------------------------------------------------------
  	public static long modInverse(long a, long m){
          long m0 = m;
          long y = 0, x = 1;
   
          if (m == 1)
              return 0;
   
          while (a > 1) {
              // q is quotient
              long q = a / m;
   
              long t = m;
   
              // m is remainder now, process
              // same as Euclid's algo
              m = a % m;
              a = t;
              t = y;
   
              // Update x and y
              y = x - q * y;
              x = t;
          }
   
          // Make x positive
          if (x < 0)
              x += m0;
   
          return x;
      }
  
  		
  
  //-----------------------------------------------------------------------------------------------------------------------------------
  
  	//segment tree
  	//for finding minimum in range 
  //	public static void build(int [] seg,int []arr,int idx, int lo , int hi) {
  //		if(lo == hi) {
  //			seg[idx] = arr[lo];
  //			return;
  //		}
  //		int mid = (lo + hi)/2;
  //	build(seg,arr,2*idx+1, lo, mid);
  //	build(seg,arr,idx*2+2, mid +1, hi);
  //	seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  //	}
  ////for finding minimum in range 
  //public static int query(int[]seg,int idx , int lo , int hi , int l , int r) {
  //		if(lo>=l && hi<=r) {
  //			return seg[idx];
  //		}
  //	if(hi<l || lo>r) {
  //		return Integer.MAX_VALUE;
  //	}
  //	int mid = (lo + hi)/2;
  //	int left = query(seg,idx*2 +1, lo, mid, l, r);
  //	int right = query(seg,idx*2 + 2, mid + 1, hi, l, r);
  //	return Math.min(left, right);
  //}
  //	// for sum
  //
  //public static void update(int[]seg,int idx, int lo , int hi , int node , int val) {
  //	if(lo == hi) {
  //		seg[idx] += val;
  //	}else {
  //int mid = (lo + hi )/2;
  //if(node<=mid && node>=lo) {
  //	update(seg, idx * 2 +1, lo, mid, node, val);
  //}else {
  //	update(seg, idx*2 + 2, mid + 1, hi, node, val);
  //}
  //seg[idx] = seg[idx*2 + 1] + seg[idx*2 + 2];
  //
  //}
  
  //}
  //---------------------------------------------------------------------------------------------------------------------------------------
  
  
  	static void shuffleArray(int[] ar)
  	  {
  	    // If running on Java 6 or older, use `new Random()` on RHS here
  	    Random rnd = ThreadLocalRandom.current();
  	    for (int i = ar.length - 1; i > 0; i--)
  	    {
  	      int index = rnd.nextInt(i + 1);
  	      // Simple swap
  	      int a = ar[index];
  	      ar[index] = ar[i];
  	      ar[i] = a;
  	    }
  	  }
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  
  }
  
  
  class FastReader {
      BufferedReader br;
      StringTokenizer st;
  
      public FastReader()
      {
          br = new BufferedReader(
              new InputStreamReader(System.in));
      }
  
      String next()
      {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
  
              
              
              
              
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
  
      int nextInt() { return Integer.parseInt(next()); }
  
      long nextLong() { return Long.parseLong(next()); }
  
      double nextDouble()
      {
          return Double.parseDouble(next());
      }
  
      String nextLine()
      {
          String str = "";
          try {
              str = br.readLine();
          }
          catch (IOException e) {
              e.printStackTrace();
          }
          return str;
      }
  }
  //------------------------------------------------------------------------------------------------------------------------------------------------------------
  class SegmentTree{
  	
  int n;
  	public SegmentTree(int[] arr,int n) {
  		this.arr = arr;
  		this.n = n;
  	}
  	int[] arr = new int[n];
  //	int n = arr.length;
  	int[] seg = new int[4*n];
  	void build(int idx, int lo , int hi) {
  		if(lo == hi) {
  			seg[idx] = arr[lo];
  			return;
  		}
  		int mid = (lo + hi)/2;
  	build(2*idx+1, lo, mid);
  	build(idx*2+2, mid +1, hi);
  	seg[idx] = Math.min(seg[2*idx+1],seg[2*idx+2]);
  	}
  	int query(int idx , int lo , int hi , int l , int r) {
  		if(lo<=l && hi>=r) {
  			return seg[idx];
  		}
  	if(hi<l || lo>r) {
  		return Integer.MAX_VALUE;
  	}
  	int mid = (lo + hi)/2;
  	int left = query(idx*2 +1, lo, mid, l, r);
  	int right = query(idx*2 + 2, mid + 1, hi, l, r);
  	return Math.min(left, right);
  	}
  	
  	
  }
  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
  class coup{
  	char a; 
  	int b;
  	public coup(char a , int b) {
  		this.a = a;
  		this.b = b;
  	}
  }
  
  class trip{
  	int a , b, c;
  	public trip(int a , int b, int c) {
  		this.a = a;
  		this.b = b;
  		this.c = c;
  	}
  }
  //---------------------------------------------------------------------------------------------------------------------------------------------------------------
  