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: //package Codeforces.Round762;
  
  
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.*;
  
  public class C {
      public static void main(String[] args) throws Exception {new C().run();}
      long mod = 1000000000 + 7;
  
      int ans=0;
      // int[][] ar;
      void solve() throws Exception {
  
          int t=ni();
          for(int o=0;o<t;o++){
  
  
              long  a= nl();
  
              long s= nl();
              String b="";
              boolean flag = false;
              while(s>0){
  
                  long d = a%10;
                  long bb = s%10;
  
                  long gh = (10+bb-d)%10;
  
                  if(gh+d==bb){
                      b += gh+"";
                      a/=10;
                      s/=10;
                  }else if(gh+d==s%100){
                      b+=(gh+"");
                      a/=10;
                      s/=100;
                  }else {
                      flag=true;break;
                  }
              }
              String ans="";
              if(a!=0) flag = true;
              boolean found=false;
              for(int i=b.length()-1;i>=0;i--) {
  
  
                  ans += b.charAt(i);
              }
              while(ans.length()>1 && ans.charAt(0)=='0'){
                  ans= ans.substring(1);
              }
              if(flag) out.println(-1);
              else out.println(ans);
  
  
  
  
          }
  
  
  
  
      }
  
  
  
      // void buildMatrix(){
      //
      // for(int i=1;i<=1000;i++){
      //
      // ar[i][1] = (i*(i+1))/2;
      //
      // for(int j=2;j<=1000;j++){
      // ar[i][j] = ar[i][j-1]+(j-1)+i-1;
      // }
      // }
      // }
  
      /* FAST INPUT OUTPUT & METHODS BELOW */
  
      private byte[] buf = new byte[1024];
      private int index;
      private InputStream in;
      private int total;
      private SpaceCharFilter filter;
      PrintWriter out;
  
      int min(int... ar) {
          int min = Integer.MAX_VALUE;
          for (int i : ar)
              min = Math.min(min, i);
          return min;
      }
  
      long min(long... ar) {
          long min = Long.MAX_VALUE;
          for (long i : ar)
              min = Math.min(min, i);
          return min;
      }
  
      int max(int... ar) {
          int max = Integer.MIN_VALUE;
          for (int i : ar)
              max = Math.max(max, i);
          return max;
      }
  
      long max(long... ar) {
          long max = Long.MIN_VALUE;
          for (long i : ar)
              max = Math.max(max, i);
          return max;
      }
  
      void shuffle(int a[]) {
          ArrayList<Integer> al = new ArrayList<>();
          for (int i = 0; i < a.length; i++)
              al.add(a[i]);
  
          Collections.sort(al);
          for (int i = 0; i < a.length; i++)
              a[i] = al.get(i);
      }
  
      long lcm(long a, long b) {
          return (a * b) / (gcd(a, b));
      }
  
      int gcd(int a, int b) {
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  
      long gcd(long a, long b) {
          if (a == 0)
              return b;
          return gcd(b % a, a);
      }
  
      /*
       * for (1/a)%mod = ( a^(mod-2) )%mod ----> use expo to calc -->(a^(mod-2))
       */
      long expo(long p, long q) /* (p^q)%mod */
      {
          long z = 1;
          while (q > 0) {
              if (q % 2 == 1) {
                  z = (z * p) % mod;
              }
              p = (p * p) % mod;
              q >>= 1;
          }
          return z;
      }
  
      void run() throws Exception {
          in = System.in;
          out = new PrintWriter(System.out);
          solve();
          out.flush();
      }
  
      private int scan() throws IOException {
          if (total < 0)
              throw new InputMismatchException();
          if (index >= total) {
              index = 0;
              total = in.read(buf);
              if (total <= 0)
                  return -1;
          }
          return buf[index++];
      }
  
      private int ni() throws IOException {
          int c = scan();
          while (isSpaceChar(c))
              c = scan();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = scan();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = scan();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
  
      private long nl() throws IOException {
          long num = 0;
          int b;
          boolean minus = false;
          while ((b = scan()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
              ;
          if (b == '-') {
              minus = true;
              b = scan();
          }
  
          while (true) {
              if (b >= '0' && b <= '9') {
                  num = num * 10 + (b - '0');
              } else {
                  return minus ? -num : num;
              }
              b = scan();
          }
      }
  
      private double nd() throws IOException {
          return Double.parseDouble(ns());
      }
  
      private String ns() throws IOException {
          int c = scan();
          while (isSpaceChar(c))
              c = scan();
          StringBuilder res = new StringBuilder();
          do {
              if (Character.isValidCodePoint(c))
                  res.appendCodePoint(c);
              c = scan();
          } while (!isSpaceChar(c));
          return res.toString();
      }
  
      private String nss() throws IOException {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          return br.readLine();
      }
  
      private char nc() throws IOException {
          int c = scan();
          while (isSpaceChar(c))
              c = scan();
          return (char) c;
      }
  
      private boolean isWhiteSpace(int n) {
          if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
              return true;
          return false;
      }
  
      private boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return isWhiteSpace(c);
      }
  
      private interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }