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.*;
  import java.util.*;
  
  import static java.lang.Math.abs;
  
  
  public class Main {
      long M = 1000000007;
      boolean multiCase = true;
  
      private void preparation() {
  
      }
  
      private void solve() throws Exception {
          rf();
          char [] a = rs2c();
          char [] s = rs2c();
          reverse(a);
          reverse(s);
          int ai = 0;
          char [] ans = new char[20];
          int si = 0;
          int i = 0;
          for(i = 0; i < s.length; i++){
              if(ai < a.length){
  
                  if(s[i] >= a[ai]){
                      ans[si++] = (char)((s[i] - a[ai]) + '0');
                  }else if(i + 1 < s.length){
                      int x = (s[i + 1] - '0') * 10 + (s[i] - a[ai]);
                      if(x >= 1 && x <= 10){
                          ans[si ++] = (char)(x + '0');
                          i++;
                      }else{
                          addAns(-1);
                          return ;
                      }
                  }else{
                      addAns(-1);
                      return ;
                  }
                  ai++;
              }else{
                  ans[si++] = s[i];
              }
  
          }
          if(ai != a.length){
              addAns(-1);
              return ;
          }
          while(si > 1 && ans[si-1] == '0'){
              si--;
          }
          ans = Arrays.copyOf(ans, si);
          reverse(ans);
          addAns(new String(ans));
      }
  
      private void clear() {
  
      }
  
      private void run() throws Exception {
  
          int T = 1;
          if (multiCase) {
              rf();
              T = ri();
          }
  
          preparation();
          while (T-- > 0) {
              solve();
              if (T != 0) {
                  clear();
              }
          }
          printAns();
      }
  
      public static void main(String[] args) throws Exception {
          new Main().run();
      }
  
      StringBuilder sb = new StringBuilder();
      BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer strT;
  
      private void addAns(int a) {
          sb.append(a).append("\n");
      }
  
      private void addAns(long a) {
          sb.append(a).append("\n");
      }
  
      private void addAns(String s) {
          sb.append(s).append("\n");
      }
  
      private void rf() throws IOException {
          strT = new StringTokenizer(infile.readLine());
      }
  
      private int ri() {
          return Integer.parseInt(strT.nextToken());
      }
  
      private long rl() {
          return Long.parseLong(strT.nextToken());
      }
  
      private char[] rs2c() {
          return strT.nextToken().toCharArray();
      }
  
      private String rs() {
          return strT.nextToken();
      }
  
  
      private int[] readArr(int N) {
          int[] arr = new int[N];
          for (int i = 0; i < N; i++) {
              arr[i] = Integer.parseInt(strT.nextToken());
          }
          return arr;
      }
  
      private long[] readArr2(int N) {
          long[] arr = new long[N];
          for (int i = 0; i < N; i++) {
              arr[i] = Long.parseLong(strT.nextToken());
          }
          return arr;
      }
  
      public boolean PRINT_FUNCTION;
  
      private void print(String format, Object... args) {
          System.out.printf((format), args);
      }
  
      // for interactive problem. flush output after print. need with tail %n if print Line Separator
      private void iprint(String format, Object... args) {
          System.out.printf((format), args);
          System.out.flush();
      }
  
      private void print(int[] arr, int x) {
          //for debugging only
          for (int i = 0; i < min(arr.length, x); i++) {
              System.out.print(arr[i] + " ");
          }
          System.out.println();
      }
  
      private void print(long[] arr, int x) {
          //for debugging only
          for (int i = 0; i < min(arr.length, x); i++) {
              System.out.print(arr[i] + " ");
          }
          System.out.println();
      }
  
      private void printAns() {
          System.out.print(sb);
      }
  
      public boolean ADD_WITH_MOD_FUNCTION;
  
      public int add(int a, int b) {
          return (int) add((long) a, (long) b);
      }
  
      public int add(int a, int b, int c) {
          return (int) add((long) a, (long) b, (long) c);
      }
  
      public int add(int a, int b, int c, int d) {
          return (int) add((long) a, (long) b, (long) c, (long) d);
      }
  
      public long add(long a, long b) {
          return (a % M + b % M) % M;
      }
  
      public long add(long a, long b, long c) {
          return (a % M + add(b, c)) % M;
      }
  
      public long add(long a, long b, long c, long d) {
          return (a % M + add(b, c, d)) % M;
      }
  
      private long mod(long x) {
          return (x % M + M) % M;
      }
  
      private int mod(int x) {
          return (int) (((x % M) + M) % M);
      }
  
      public boolean ELEMENT_COUNT_TO_MAP_FUNCTION;
  
      private HashMap<Integer, Integer> hash(int[] A) {
          HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
          for (int i : A) {
              if (map.containsKey(i)) {
                  map.put(i, map.get(i) + 1);
              } else {
                  map.put(i, 1);
              }
          }
          return map;
      }
  
      private HashMap<Long, Integer> hash(long[] A) {
          HashMap<Long, Integer> map = new HashMap<Long, Integer>();
          for (long i : A) {
              if (map.containsKey(i)) {
                  map.put(i, map.get(i) + 1);
              } else {
                  map.put(i, 1);
              }
          }
          return map;
      }
  
      private TreeMap<Integer, Integer> tree(int[] A) {
          TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
          for (int i : A) {
              if (map.containsKey(i)) {
                  map.put(i, map.get(i) + 1);
              } else {
                  map.put(i, 1);
              }
          }
          return map;
      }
  
      private TreeMap<Long, Integer> tree(long[] A) {
          TreeMap<Long, Integer> map = new TreeMap<Long, Integer>();
          for (long i : A) {
              if (map.containsKey(i)) {
                  map.put(i, map.get(i) + 1);
              } else {
                  map.put(i, 1);
              }
          }
          return map;
      }
  
      public boolean SORT_FUNCTION;
  
      private void sort(int[] A) {
          int n = A.length;
          Random rnd = new Random();
          for (int i = 0; i < n; ++i) {
              int tmp = A[i];
              int randomPos = i + rnd.nextInt(n - i);
              A[i] = A[randomPos];
              A[randomPos] = tmp;
          }
          Arrays.sort(A);
      }
  
      private void sort(long[] A) {
          int n = A.length;
          Random rnd = new Random();
          for (int i = 0; i < n; ++i) {
              long tmp = A[i];
              int randomPos = i + rnd.nextInt(n - i);
              A[i] = A[randomPos];
              A[randomPos] = tmp;
          }
          Arrays.sort(A);
      }
  
      private String sort(String s) {
          Character[] ch = new Character[s.length()];
          for (int i = 0; i < s.length(); i++) {
              ch[i] = s.charAt(i);
          }
          Arrays.sort(ch);
          StringBuilder st = new StringBuilder();
          for (int i = 0; i < s.length(); i++) {
              st.append(ch[i]);
          }
          return st.toString();
      }
  
      public boolean REVERSE_FUNCTION;
  
      private String reverse(String s) {
          StringBuilder p = new StringBuilder(s);
          p.reverse();
          return p.toString();
      }
  
      private long sum(int[] A) {
          long sum = 0;
          for (int i : A) {
              sum += i;
          }
          return sum;
      }
  
      private long sum(long[] A) {
          long sum = 0;
          for (long i : A) {
              sum += i;
          }
          return sum;
      }
  
      private void reverse(long[] A) {
          int n = A.length;
          long[] B = new long[n];
          for (int i = 0; i < n; i++) {
              B[i] = A[n - i - 1];
          }
          System.arraycopy(B, 0, A, 0, n);
  
      }
  
      private void reverse(int[] A) {
          int n = A.length;
          int[] B = new int[n];
          for (int i = 0; i < n; i++) {
              B[i] = A[n - i - 1];
          }
          System.arraycopy(B, 0, A, 0, n);
  
      }
      private void reverse(char[] A) {
          int n = A.length;
          char[] B = new char[n];
          for (int i = 0; i < n; i++) {
              B[i] = A[n - i - 1];
          }
          System.arraycopy(B, 0, A, 0, n);
  
      }
  
      private int nextPowerOf2(int n) {
          n--;
          n |= n >> 1;
          n |= n >> 2;
          n |= n >> 4;
          n |= n >> 8;
          n |= n >> 16;
          n++;
  
          return n;
      }
  
      private int highestPowerOf2(int x) {
  
          x |= x >> 1;
          x |= x >> 2;
          x |= x >> 4;
          x |= x >> 8;
          x |= x >> 16;
  
          return x ^ (x >> 1);
  
      }
  
      private long highestPowerOf2(long x) {
  
          x |= x >> 1;
          x |= x >> 2;
          x |= x >> 4;
          x |= x >> 8;
          x |= x >> 16;
          return x ^ (x >> 1);
  
      }
  
      public boolean ARRAY_MAX_MIN_FUNCTION;
  
      private int max(int[] A) {
          int max = Integer.MIN_VALUE;
          for (int j : A) {
              max = Math.max(max, j);
          }
          return max;
      }
  
      private int min(int[] A) {
          int min = Integer.MAX_VALUE;
          for (int j : A) {
              min = Math.min(min, j);
          }
          return min;
      }
  
      private long max(long[] A) {
          long max = Long.MIN_VALUE;
          for (long l : A) {
              max = Math.max(max, l);
          }
          return max;
      }
  
      private long min(long[] A) {
          long min = Long.MAX_VALUE;
          for (long l : A) {
              min = Math.min(min, l);
          }
          return min;
      }
  
      public boolean PREFIX_SUFFIX_FUNCTION;
  
      private long[] prefix(long[] A) {
          long[] p = new long[A.length];
          p[0] = A[0];
          for (int i = 1; i < A.length; i++)
              p[i] = p[i - 1] + A[i];
          return p;
      }
  
      private long[] prefix(int[] A) {
          long[] p = new long[A.length];
          p[0] = A[0];
          for (int i = 1; i < A.length; i++)
              p[i] = p[i - 1] + A[i];
          return p;
      }
  
      private long[] suffix(long[] A) {
          long[] p = new long[A.length];
          p[A.length - 1] = A[A.length - 1];
          for (int i = A.length - 2; i >= 0; i--)
              p[i] = p[i + 1] + A[i];
          return p;
      }
  
      private long[] suffix(int[] A) {
          long[] p = new long[A.length];
          p[A.length - 1] = A[A.length - 1];
          for (int i = A.length - 2; i >= 0; i--)
              p[i] = p[i + 1] + A[i];
          return p;
      }
  
      public boolean FILL_ARRAY_FUNCTION;
  
      private void fill(int[] dp, int v) {
          Arrays.fill(dp, v);
      }
  
      private void fill(int[][] dp, int v) {
          for (int[] ints : dp) {
              Arrays.fill(ints, v);
          }
      }
  
      private void fill(int[][][] dp, int v) {
          for (int i = 0; i < dp.length; i++) {
              for (int j = 0; j < dp[0].length; j++) {
                  Arrays.fill(dp[i][j], v);
              }
          }
      }
  
      private void fill(int[][][][] dp, int v) {
          for (int i = 0; i < dp.length; i++) {
              for (int j = 0; j < dp[0].length; j++) {
                  for (int k = 0; k < dp[0][0].length; k++) {
                      Arrays.fill(dp[i][j][k], v);
                  }
              }
          }
      }
  
      private void fill(long[] dp, long v) {
          Arrays.fill(dp, v);
      }
  
      private void fill(long[][] dp, long v) {
          for (long[] longs : dp) Arrays.fill(longs, v);
      }
  
      private void fill(long[][][] dp, long v) {
          for (long[][] ones : dp) {
              for (long[] two : ones) {
                  Arrays.fill(two, v);
              }
          }
      }
  
      private void fill(long[][][][] dp, long v) {
          for (int i = 0; i < dp.length; i++) {
              for (int j = 0; j < dp[0].length; j++) {
                  for (int k = 0; k < dp[0][0].length; k++) {
                      Arrays.fill(dp[i][j][k], v);
                  }
              }
          }
      }
  
      public boolean MAX_AND_MIN_FUNCTION;
      // max and min for 2 ~ 4 arguments, argument Type int long float double
  
      private int min(int a, int b) {
          return Math.min(a, b);
      }
  
      private long min(long a, long b) {
          return Math.min(a, b);
      }
  
      private float min(float a, float b) {
          return Math.min(a, b);
      }
  
      private double min(double a, double b) {
          return Math.min(a, b);
      }
  
  
      private int min(int a, int b, int c) {
          return Math.min(a, Math.min(b, c));
      }
  
      private float min(float a, float b, float c) {
          return Math.min(a, Math.min(b, c));
      }
  
      private double min(double a, double b, double c) {
          return Math.min(a, Math.min(b, c));
      }
  
      private long min(long a, long b, long c) {
          return Math.min(a, Math.min(b, c));
      }
  
      private int min(int a, int b, int c, int d) {
          return Math.min(Math.min(a, b), Math.min(c, d));
      }
  
      private long min(long a, long b, long c, long d) {
          return Math.min(Math.min(a, b), Math.min(c, d));
      }
  
      private float min(float a, float b, float c, float d) {
          return Math.min(Math.min(a, b), Math.min(c, d));
      }
  
      private double min(double a, double b, double c, double d) {
          return Math.min(Math.min(a, b), Math.min(c, d));
      }
  
      private int max(int a, int b) {
          return Math.max(a, b);
      }
  
      private long max(long a, long b) {
          return Math.max(a, b);
      }
  
      private float max(float a, float b) {
          return Math.max(a, b);
      }
  
      private double max(double a, double b) {
          return Math.max(a, b);
      }
  
      private int max(int a, int b, int c) {
          return Math.max(a, Math.max(b, c));
      }
  
      private float max(float a, float b, float c) {
          return Math.max(a, Math.max(b, c));
      }
  
      private double max(double a, double b, double c) {
          return Math.max(a, Math.max(b, c));
      }
  
      private long max(long a, long b, long c) {
          return Math.max(a, Math.max(b, c));
      }
  
      private int max(int a, int b, int c, int d) {
          return Math.max(Math.max(a, b), Math.max(c, d));
      }
  
      private long max(long a, long b, long c, long d) {
          return Math.max(Math.max(a, b), Math.max(c, d));
      }
  
      private float max(float a, float b, float c, float d) {
          return Math.max(Math.max(a, b), Math.max(c, d));
      }
  
      private double max(double a, double b, double c, double d) {
          return Math.max(Math.max(a, b), Math.max(c, d));
      }
  
  }
  