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.Arrays;
  import java.util.Locale;
  import java.util.StringTokenizer;
  
  public class C {
  
      private final boolean MULTI_TEST = true;
      private final String FILE_NAME = "";
  
      private int getInt(char c) {
          return c - '0';
      }
  
      private void solve() {
          String a = rs(), r = rs(); // b - ?
          String res = "";
          int aIndex = a.length() - 1;
          int rIndex = r.length() - 1;
          try {
              while (aIndex >= 0 && rIndex >= 0) {
                  if (getInt(a.charAt(aIndex)) > getInt(r.charAt(rIndex))) {
                      int first = Integer.parseInt(r.substring(rIndex - 1, rIndex + 1));
                      int second = getInt(a.charAt(aIndex));
                      res = (first - second) + res;
                      if (first - second >= 10 || getInt(r.charAt(rIndex - 1)) != 1) {
                          res = "-1";
                          break;
                      }
                      aIndex--;
                      rIndex -= 2;
                  } else {
                      res = getInt(r.charAt(rIndex)) - getInt(a.charAt(aIndex)) + res;
                      aIndex--;
                      rIndex--;
                  }
              }
  
          }catch (Exception e) {
              res = "-1";
              aIndex = -1;
              rIndex = - 1;
          }
          try {
              if (rIndex >= 0 && !res.equals("-1")) {
                  res = r.substring(0, rIndex + 1) + res;
                  rIndex = -1;
              }
          } catch (Exception e) {
              res = "-1";
          }
          if(aIndex >= 0 || rIndex >= 0) {
              out.println(-1);
          } else {
              while(res.startsWith("0")) res = res.substring(1);
              if(res.isEmpty()) res = "0";
              out.println(res);
          }
      }
  
      //////////////////////////////////////////////////////////////////
  
      long sqrtLong(long x) {
          long root = (long) Math.sqrt(x);
          while (root * root > x) --root;
          while ((root + 1) * (root + 1) <= x) ++root;
          return root;
      }
  
      int gcd(int a, int b) {
          if (b == 0)
              return a;
          else
              return gcd(b, a % b);
      }
  
      int lcm(int a, int b) {
          return a / gcd(a, b) * b;
      }
  
      int phi(int n) {
          int result = n;
          for (int i = 2; i * i <= n; ++i)
              if (n % i == 0) {
                  while (n % i == 0)
                      n /= i;
                  result -= result / i;
              }
          if (n > 1)
              result -= result / n;
          return result;
      }
  
      int factmod(int n, int p) {
          int res = 1;
          while (n > 1) {
              res = (res * ((n / p) % 2 == 1 ? p - 1 : 1)) % p;
              for (int i = 2; i <= n % p; ++i)
                  res = (res * i) % p;
              n /= p;
          }
          return res % p;
      }
  
      int binpow(int a, int n) {
          int res = 1;
          while (n != 0) {
              if ((n & 1) != 0)
                  res *= a;
              a *= a;
              n >>= 1;
          }
          return res;
      }
  
      String solPyatnashki() {
          int a[] = new int[16];
          for (int i = 0; i < 16; ++i)
              a[i] = ri();
  
          int inv = 0;
          for (int i = 0; i < 16; ++i)
              if (a[i] != 0)
                  for (int j = 0; j < i; ++j)
                      if (a[j] > a[i])
                          ++inv;
          for (int i = 0; i < 16; ++i)
              if (a[i] == 0)
                  inv += 1 + i / 4;
  
  
          return ((inv & 1) != 0 ? "No Solution" : "Solution Exists");
      }
  
      boolean isPrime(int number) {
          for (int i = 2; i * i <= number; i++) {
              if (number % i == 0) {
                  return false;
              }
          }
          return number > 1;
      }
  
      boolean[] primes(int border) {
          boolean[] isPrimes = new boolean[border + 1];
          Arrays.fill(isPrimes, true);
          isPrimes[0] = false;
          isPrimes[1] = false;
          for (int i = 2; i < border + 1; i++) {
              if (!isPrimes[i]) continue;
              for (int k = i * 2; k < border; k += i) {
                  isPrimes[k] = false;
              }
          }
          return isPrimes;
      }
  
      int[] sort(int[] arr) {
          Integer[] a = new Integer[arr.length];
          for (int i = 0; i < arr.length; i++) {
              a[i] = arr[i];
          }
          Arrays.sort(a);
          for (int i = 0; i < a.length; i++) {
              arr[i] = a[i];
          }
          return arr;
      }
  
      long[] sort(long[] arr) {
          Long[] a = new Long[arr.length];
          for (int i = 0; i < arr.length; i++) {
              a[i] = arr[i];
          }
          Arrays.sort(a);
          for (int i = 0; i < a.length; i++) {
              arr[i] = a[i];
          }
          return arr;
      }
  
      int max(int[] a) {
          int max = Integer.MIN_VALUE;
          for (int i = 0; i < a.length; i++) {
              if (a[i] > max) max = a[i];
          }
          return max;
      }
  
      long fastMod(String s1, long n2) {
          long num = 0;
          for (int i = 0; i < s1.length() - 1; i++) {
              num += Integer.parseInt(String.valueOf(s1.charAt(i)));
              num *= 10;
              if (num >= n2) {
                  num = num % n2;
              }
          }
          return (num + Integer.parseInt(String.valueOf(s1.charAt(s1.length() - 1)))) % n2;
      }
  
      //////////////////////////////////////////////////////////////////
  
      private boolean yesNo(boolean yes) {
          return yesNo(yes, "YES", "NO");
      }
  
      private boolean yesNo(boolean yes, String yesString, String noString) {
          out.println(yes ? yesString : noString);
          return yes;
      }
  
      //////////////////////////////////////////////////////////////////
  
      private long rl() {
          return Long.parseLong(rs());
      }
  
      private double rd() {
          return Double.parseDouble(rs());
      }
  
      private int[] ria(int n) {
          int[] a = new int[n];
          for (int i = 0; i < n; ++i) a[i] = ri();
          return a;
      }
  
      private int ri() {
          return Integer.parseInt(rs());
      }
  
      private String rs() {
          while (!tok.hasMoreTokens()) {
              String nextLine = readLine();
              if (null == nextLine) return null;
              tok = new StringTokenizer(nextLine);
          }
  
          return tok.nextToken();
      }
  
      private String readLine() {
          try {
              return in.readLine();
          } catch (IOException e) {
              throw new RuntimeException(e);
          }
      }
  
      //////////////////////////////////////////////////////////////////
  
      private BufferedReader in;
      private StringTokenizer tok;
      private PrintWriter out;
  
      private void initFileIO(String inputFileName, String outputFileName) throws FileNotFoundException {
          in = new BufferedReader(new FileReader(inputFileName));
          out = new PrintWriter(outputFileName);
      }
  
      private void initConsoleIO() throws IOException {
          in = new BufferedReader(new InputStreamReader(System.in));
          out = new PrintWriter(System.out);
      }
  
      private void initIO() throws IOException {
          Locale.setDefault(Locale.US);
  
          if (!FILE_NAME.isEmpty()) {
              initFileIO(FILE_NAME + ".in", FILE_NAME + ".out");
          } else {
              if (new File("input.txt").exists()) {
                  initFileIO("input.txt", "output.txt");
              } else {
                  initConsoleIO();
              }
          }
  
          tok = new StringTokenizer("");
      }
  
      //////////////////////////////////////////////////////////////////
  
      private void run() {
          try {
              long timeStart = System.currentTimeMillis();
              initIO();
              if (MULTI_TEST) {
                  int t = ri();
                  while (t-- > 0) {
                      solve();
                      out.flush();
                  }
              } else
                  solve();
              out.close();
              long timeEnd = System.currentTimeMillis();
              System.err.println("Time(ms) = " + (timeEnd - timeStart));
          } catch (Exception e) {
              e.printStackTrace();
              throw new RuntimeException(e);
          }
      }
  
      public static void main(String[] args) {
          new C().run();
      }
  
      ///////////////////////////////////////////////////////////////////
  }