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 com.company;
  
  import java.io.*;
  import java.math.BigInteger;
  import java.util.*;
  
  public class Main{
  
      static boolean[] primecheck = new boolean[1000002];
  
      public static void main(String[] args) {
          OutputStream outputStream = System.out;
          FastReader in = new FastReader();
          PrintWriter out = new PrintWriter(outputStream);
          PROBLEM solver = new PROBLEM();
          int t = 1;
          t = in.nextInt();
          for (int i = 0; i < t; i++) {
              solver.solve(in, out);
          }
          out.close();
      }
  
      static ArrayList<Integer> adj[];
      static int[] vis;
      static long cnt = 0;
      static long mod = (long)1e9 + 7;
  
      static class PROBLEM {
  
          static void swap(int[] a, int l, int r) {
              int temp = a[l];
              a[l] = a[r];
              a[r] = temp;
          }
  
          public void solve(FastReader in, PrintWriter out) {
  
              long a = in.nextLong(), s = in.nextLong(), b = 0;
              Stack<Long> st = new Stack<>();
  
              while(s>0){
  
                  long x = a%10;
                  a/=10;
                  long y = s%10;
                  s/=10;
  
                  long need = y-x;
  
                  if(need<0){
                      need+=10;
                      if(s%10 != 1){
                          out.println(-1);
                          return;
                      }
                      s/=10;
                  }
  
                  st.push(need);
              }
  
              if(a != 0){
                  out.println(-1);
                  return;
              }
  
              while(st.peek() == 0) st.pop();
  
              while(!st.isEmpty()){
                  out.print(st.pop());
              }
  
  
              out.println();
  
  //            int n = in.nextInt(), a[] = in.readArray(n);
  //            int[] f = new int[200001];
  //
  //            for (int i = 0; i < n; i++) {
  //                f[a[i]]++;
  //            }
  //
  //            int psum = 0, z = 0, zm = 0;
  //            int[] ans = new int[n+1];
  //            if(f[0] > 0) ans[0] = f[0];
  //            else ans[0] = -1;
  //
  //            for (int i = 1; i <= n; i++) {
  //
  //                psum += f[i-1];
  //
  //
  //                if(f[i] == 0){
  //                    z++;
  //                    zm += i;
  //                }
  //
  //                if(psum < i){
  //                    ans[i] = -1;
  //                    continue;
  //                }
  //
  //                if(ans[i-1] == -1) ans[i] = -1;
  //                else{
  //                    if(f[i] != 0){
  //                        ans[i] = ans[i-1] + f[i];
  //                    }else {
  //                        if (z == 1){
  //                            ans[i] = 0;
  ////                            int j = i-1;
  ////                            while(j >=0 && f[j] < 1) j--;
  ////                            if(j >= 0){
  ////                                f[j]--;
  ////                                f[i]++;
  ////                            }
  //                        }
  //                        else {
  //                            int j = i-1;
  //                            while(j >=0 && f[j] < 1) j--;
  //                            if(j >= 0){
  //                                f[j]--;
  //                                f[i]++;
  //                                ans[i] = i-j;
  //                            }
  //                        }
  //                    }
  //                }
  //            }
  //
  //            for (int i = 0; i < n+1; i++) {
  //                out.print(ans[i] + " ");
  //            }
  //            out.println();
  //
  
          }
  
  
  
  
          }
  
      static void dfs(int i){
          vis[i] = 1;
          cnt++;
  
          for(int j: adj[i]){
              if(vis[j] == 0)
                  dfs(j);
          }
      }
  
      static HashMap<Integer, Integer> initializeMap(int n){
          HashMap<Integer,Integer> hm = new HashMap<>();
          for (int i = 0; i <= n; i++) {
              hm.put(i, 0);
          }
          return hm;
      }
  
      static boolean isRegular(char[] c){
  
          Stack<Character> s = new Stack<>();
          for (char value : c) {
              if (s.isEmpty() && value == ')') return false;
  
              if (value == '(') s.push(value);
              else s.pop();
          }
  
          return s.isEmpty();
      }
  
      static ArrayList<ArrayList<Integer>> createAdj(int n, int e){
  
          FastReader in = new FastReader();
          ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
  
          for (int i = 0; i < n + 1; i++) {
              adj.add(new ArrayList<>());
          }
  
          for (int i = 0; i < e; i++) {
  
              int a = in.nextInt(), b = in.nextInt();
              System.out.println(a);
  
              adj.get(a).add(b);
              adj.get(b).add(a);
          }
  
  
          return adj;
      }
  
      static int binarySearch(int[] a, int l, int r, int x){
          if(r>=l){
              int mid = l + (r-l)/2;
  
              if(a[mid] == x) return mid;
  
              if(a[mid] > x) return binarySearch(a, l, mid-1, x);
              else return binarySearch(a,mid+1, r, x);
          }
          return -1;
      }
  
      static boolean isPalindromeI(int n){
  
          int d = 0;
          int y = n;
          while(y>0){
              d++;
              y/=10;
          }
  
          int[] a = new int[d];
          for (int i = 0; i < d; i++) {
              a[i] = n%10;
              n/=10;
          }
  
          System.out.println(Arrays.toString(a));
          for (int i = 0; i < d / 2; i++) {
              if(a[i] != a[d-i-1]) return false;
          }
          return true;
      }
  
      static long gcd(long a, long b) {
          if (b == 0) return a;
          return gcd(b, a % b);
      }
  
      static long lcm(long a, long b)
      {
          return (a / gcd(a, b)) * b;
      }
  
      static boolean isSquare(double a) {
          boolean isSq = false;
          double b = Math.sqrt(a);
          double c = Math.sqrt(a) - Math.floor(b);
  
          if (c == 0) isSq = true;
  
          return isSq;
      }
  
      static long fast_pow(long a, long b) { //Jeel bhai OP
          if(b == 0)
              return 1L;
  
          long val = fast_pow(a, b / 2);
  
          if(b % 2 == 0)
              return val * val % mod;
          else
              return val * val % mod * a % mod;
      }
  
      static int exponentMod(int A, int B, int C) {
  
          // Base cases
          if (A == 0)
              return 0;
          if (B == 0)
              return 1;
  
          // If B is even
          long y;
          if (B % 2 == 0) {
              y = exponentMod(A, B / 2, C);
              y = (y * y) % C;
          }
  
          // If B is odd
          else {
              y = A % C;
              y = (y * exponentMod(A, B - 1, C) % C) % C;
          }
  
          return (int) ((y + C) % C);
      }
  
  
      static class Pair implements Comparable<Pair>{
  
          char x;
          int y;
  
          Pair(char x, int y){
              this.x = x;
              this.y = y;
          }
  
          public int compareTo(Pair o){
              int ans = Integer.compare(x, o.x);
              if(o.x == x) ans = Integer.compare(y, o.y);
  
              return ans;
          }
      }
  
      static class Tuple implements Comparable<Tuple>{
  
          int x, y, id;
  
          Tuple(int x, int y, int id){
              this.x = x;
              this.y = y;
              this.id = id;
          }
  
          public int compareTo(Tuple o){
              int ans = Integer.compare(x, o.x);
              if(o.x == x) ans = Integer.compare(y, o.y);
  
              return ans;
          }
      }
  
  //    public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
  //        public U x;
  //        public V y;
  //
  //        public Pair(U x, V y) {
  //            this.x = x;
  //            this.y = y;
  //        }
  //
  //        public int hashCode() {
  //            return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode());
  //        }
  //
  //        public boolean equals(Object o) {
  //            if (this == o)
  //                return true;
  //            if (o == null || getClass() != o.getClass())
  //                return false;
  //            Pair<U, V> p = (Pair<U, V>) o;
  //            return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y));
  //        }
  //
  //        public int compareTo(Pair<U, V> b) {
  //            int cmpU = x.compareTo(b.x);
  //            return cmpU != 0 ? cmpU : y.compareTo(b.y);
  //        }
  //
  //        public int compareToY(Pair<U, V> b) {
  //            int cmpU = y.compareTo(b.y);
  //            return cmpU != 0 ? cmpU : x.compareTo(b.x);
  //        }
  //
  //        public String toString() {
  //            return String.format("(%s, %s)", x.toString(), y.toString());
  //        }
  //
  //    }
  
      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());
          }
  
          char nextChar() {
              return next().charAt(0);
          }
  
          boolean nextBoolean() {
              return !(nextInt() == 0);
          }
          // boolean nextBoolean(){return Boolean.parseBoolean(next());}
  
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
  
          public int[] readArray(int size) {
              int[] array = new int[size];
              for (int i = 0; i < size; i++) array[i] = nextInt();
              return array;
          }
  
      }
  
      private static int[] mergeSort(int[] array) {
  
          //array.length replaced with ctr
          int ctr = array.length;
          if (ctr <= 1) {
              return array;
          }
  
          int midpoint = ctr / 2;
  
          int[] left = new int[midpoint];
          int[] right;
  
          if (ctr % 2 == 0) {
              right = new int[midpoint];
          } else {
              right = new int[midpoint + 1];
          }
  
          for (int i = 0; i < left.length; i++) {
              left[i] = array[i];
          }
  
          for (int i = 0; i < right.length; i++) {
              right[i] = array[i + midpoint];
          }
  
          left = mergeSort(left);
          right = mergeSort(right);
  
          int[] result = merge(left, right);
  
          return result;
      }
  
      private static int[] merge(int[] left, int[] right) {
  
          int[] result = new int[left.length + right.length];
          int leftPointer = 0, rightPointer = 0, resultPointer = 0;
  
          while (leftPointer < left.length || rightPointer < right.length) {
  
              if (leftPointer < left.length && rightPointer < right.length) {
  
                  if (left[leftPointer] < right[rightPointer]) {
                      result[resultPointer++] = left[leftPointer++];
                  } else {
                      result[resultPointer++] = right[rightPointer++];
                  }
              } else if (leftPointer < left.length) {
                  result[resultPointer++] = left[leftPointer++];
              } else {
                  result[resultPointer++] = right[rightPointer++];
              }
          }
          return result;
      }
  
      public static void Sieve(int n) {
  
          Arrays.fill(primecheck, true);
          primecheck[0] = false;
          primecheck[1] = false;
  
          for (int i = 2; i * i < n + 1; i++) {
              if (primecheck[i]) {
                  for (int j = i * 2; j < n + 1; j += i) {
                      primecheck[j] = false;
                  }
              }
          }
      }
  }
  
  
  