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.IOException;
  import java.io.InputStreamReader;
  import java.util.Arrays;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.List;
  import java.util.StringTokenizer;
   
  public class Main {
  	static FastReader fr;
  	static int arrForIndexSort[];
  	static Integer map1[];
  	static Integer map2[];
  	
  	static 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;
          }
      }
  	static class Pair{
  		int first;
  		int second;
  		Pair(int first, int second){
  			this.first = first;
  			this.second = second;
  		}
  		@Override
  		public boolean equals(Object b) {
  			Pair a = (Pair)b;
  			if(this.first == a.first && this.second==a.second) {
  				return true;
  			}
  			return false;
  		}
  	}
  	class PairSorter implements Comparator<Main.Pair>{
  		public int compare(Pair a, Pair b) {
  			if(a.first!=b.first) {
  				return a.first-b.first;
  			}
  			return a.second-b.second; 
  		}
  	}
  	static class DoublePair{
  		double first;
  		double second;
  		DoublePair(double first, double second){
  			this.first = first;
  			this.second = second;
  		}
  		@Override
  		public boolean equals(Object b) {
  			Pair a = (Pair)b;
  			if(this.first == a.first && this.second==a.second) {
  				return true;
  			}
  			return false;
  		}
  	}
  	class DoublePairSorter implements Comparator<Main.DoublePair>{
  		public int compare(DoublePair a, DoublePair b) {
  			 if(a.second>b.second) {
  				 return 1;
  			 }
  			 else if(a.second<b.second) {
  				 return -1;
  			 }
  			 return 0;
  		}
  	}
  	class IndexSorter implements Comparator<Integer>{
  		public int compare(Integer a, Integer b) {
  			//desc
  			if(arrForIndexSort[b]==arrForIndexSort[a]) {
  				return b-a;
  			}
  			return arrForIndexSort[b]-arrForIndexSort[a];
  		}
  	}
  	class ListSorter implements Comparator<List>{
  		public int compare(List a, List b) {
  			return b.size()-a.size(); 
  		}
  	}
  	static class DisjointSet{
  		int[] dsu;
  		public DisjointSet(int n) {
  			makeSet(n);
  		}
  		public void makeSet(int n) {
  			dsu = new int[n+1];
  			//*** 1 Based indexing ***
  			for(int i=1;i<=n;i++) {
  				dsu[i] = -1;
  			}
  		}
  		public int find(int i) {
  			while(dsu[i] > 0) {
  				i = dsu[i];
  			}
  			return i;
  		}
  		public void union(int i, int j) {
  			int iRep = find(i);
  			int jRep = find(j);
  			if(iRep == jRep) {
  				return;
  			}
  			if(dsu[iRep]>dsu[jRep]) {
  				dsu[jRep] += dsu[iRep];
  				dsu[iRep] = jRep;
  			}
  			else {
  				dsu[iRep] += dsu[jRep];
  				dsu[jRep] = iRep;
  			}
  		}
  	}
  	public static void main(String[] args) {
  		fr = new FastReader();
  		int T = 1;
  		T = fr.nextInt();
  		int t1 = T;
  		while (T-- > 0) {
  			solve(T-t1);
  		}
  	}
  	public static void solve(int testcase) {
  		long a = fr.nextLong();
  		long c = fr.nextLong();
  		long A = a;
  		long C = c;
  		long b = 0;
  		long counter = 1;
  		boolean res = false;
  		while(a>0) {
  			if(c==0) {
  				break;
  			}
  			long ad = a%10;
  			a/=10;
  			long cd = c%10;
  			c/=10;
  			if(ad>cd) {
  				cd = (10*(c%10))+cd;
  				c/=10;
  			}
  			long diff = cd-ad;
  			if(diff>9 || ad>cd) {
  				res = true;
  				break;
  			}
  			b = (counter)*diff+b;
  			counter*=10;
  		}
  		b = counter*c+b;
  
  		if(a>0 || res) {
  			System.out.println(-1);
  		}
  		else {
  			System.out.println(b);
  		}
  	}
  
  }