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: from __future__ import division, print_function
  
  import os
  import sys
  from io import BytesIO, IOBase
  
  if sys.version_info[0] < 3:
      from __builtin__ import xrange as range
      from future_builtins import ascii, filter, hex, map, oct, zip
  
  
  class LazySegmentTree:
      def __init__(self, data, default=0, func=max):
          """initialize the lazy segment tree with data"""
          self._default = default
          self._func = func
  
          self._len = len(data)
          self._size = _size = 1 << (self._len - 1).bit_length()
          self._lazy = [pow(2,30)-1] * (2 * _size)
  
          self.data = [default] * (2 * _size)
          self.data[_size:_size + self._len] = data
          for i in reversed(range(_size)):
              self.data[i] = func(self.data[i + i], self.data[i + i + 1])
  
      def __len__(self):
          return self._len
  
      def _push(self, idx):
          """push query on idx to its children"""
          # Let the children know of the queries
          q, self._lazy[idx] = self._lazy[idx], pow(2,30)-1
  
          self._lazy[2 * idx] &= q
          self._lazy[2 * idx + 1] &= q
          self.data[2 * idx] &= q
          self.data[2 * idx + 1] &= q
  
      def _update(self, idx):
          """updates the node idx to know of all queries applied to it via its ancestors"""
          for i in reversed(range(1, idx.bit_length())):
              self._push(idx >> i)
  
      def _build(self, idx):
          """make the changes to idx be known to its ancestors"""
          idx >>= 1
          while idx:
              self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1]) & self._lazy[idx]
              idx >>= 1
  
      def add(self, start, stop, value):
          """lazily add value to [start, stop)"""
          start = start_copy = start + self._size
          stop = stop_copy = stop + self._size
          while start < stop:
              if start & 1:
                  self._lazy[start] &= value
                  self.data[start] &= value
                  start += 1
              if stop & 1:
                  stop -= 1
                  self._lazy[stop] &= value
                  self.data[stop] &= value
              start >>= 1
              stop >>= 1
  
          # Tell all nodes above of the updated area of the updates
          self._build(start_copy)
          self._build(stop_copy - 1)
  
      def query(self, start, stop, default=0):
          """func of data[start, stop)"""
          start += self._size
          stop += self._size
  
          # Apply all the lazily stored queries
          self._update(start)
          self._update(stop - 1)
  
          res = default
          while start < stop:
              if start & 1:
                  res = self._func(res, self.data[start])
                  start += 1
              if stop & 1:
                  stop -= 1
                  res = self._func(res, self.data[stop])
              start >>= 1
              stop >>= 1
          return res
  
      def __repr__(self):
          return "LazySegmentTree({0})".format(self.data)
  default=pow(2,30)-1
  mod=10**9+7
  def xorSum(arr, n):
      bits = 0
      for i in range(n):
          bits |= arr[i]
      ans = (bits * pow(2, n-1,mod))%mod
      return ans
  from math import sqrt,ceil
  def find(a,i,j):
      if(i==0 and j==len(a)-1):
          return float("Inf")
      n=len(a)
      if((n-(j-i+1))//2<i):
          return a[(n-(j-i+1))//2]
      else:
          return a[j+(n-(j-i+1))//2-i+1]
  def chk(i,j,a):
      bichwale=j-i-1
  from math import *
  def SquareCube( N):
   
      cnt, i = 0, 1
   
      while (i ** 6 <= N):
          cnt += 1
          i += 1
   
      return cnt
  def cube(N):
      cnt, i = 0, 1
   
      while (i ** 3 <= N):
          cnt += 1
          i += 1
   
      return cnt
  def square(N):
      cnt, i = 0, 1
   
      while (i ** 2 <= N):
          cnt += 1
          i += 1
   
      return cnt
  def main():
      for _ in range(int(input())):
          try:
              a,s=input().split()
              b=[]
              t=len(s)-1
              f=True
              for i in a[::-1]:
                  if(t<0):
                      f=False
                      break
                  if(int(i)>int(s[t])):
                      if(t>0):
                          if(int(s[t-1:t+1])>=19):
                              f=False
                              break
                          b.append(int(s[t-1:t+1])-int(i))
                          t-=1
                      else:
                          f=False
                          break
                  else:
                      b.append(int(s[t])-int(i))
                  t-=1
              if(t>=0):
                  b.append(int(s[:t+1]))
              b=b[::-1]
              if(f):
                  print(int("".join(map(str,b))))
              else:
                  print(-1)
          except:
              print(-1)
              
                   
              
              
                  
  
  
              
  
      
  
  
  # region fastio
  
  BUFSIZE = 8192
  
  
  class FastIO(IOBase):
      newlines = 0
  
      def __init__(self, file):
          self._fd = file.fileno()
          self.buffer = BytesIO()
          self.writable = "x" in file.mode or "r" not in file.mode
          self.write = self.buffer.write if self.writable else None
  
      def read(self):
          while True:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              if not b:
                  break
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines = 0
          return self.buffer.read()
  
      def readline(self):
          while self.newlines == 0:
              b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
              self.newlines = b.count(b"\n") + (not b)
              ptr = self.buffer.tell()
              self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
          self.newlines -= 1
          return self.buffer.readline()
  
      def flush(self):
          if self.writable:
              os.write(self._fd, self.buffer.getvalue())
              self.buffer.truncate(0), self.buffer.seek(0)
  
  
  class IOWrapper(IOBase):
      def __init__(self, file):
          self.buffer = FastIO(file)
          self.flush = self.buffer.flush
          self.writable = self.buffer.writable
          self.write = lambda s: self.buffer.write(s.encode("ascii"))
          self.read = lambda: self.buffer.read().decode("ascii")
          self.readline = lambda: self.buffer.readline().decode("ascii")
  
  
  def print(*args, **kwargs):
      """Prints the values to a stream, or to sys.stdout by default."""
      sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
      at_start = True
      for x in args:
          if not at_start:
              file.write(sep)
          file.write(str(x))
          at_start = False
      file.write(kwargs.pop("end", "\n"))
      if kwargs.pop("flush", False):
          file.flush()
  
  
  if sys.version_info[0] < 3:
      sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
  else:
      sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
  
  input = lambda: sys.stdin.readline().rstrip("\r\n")
  
  # endregion
  
  if __name__ == "__main__":
      main()
  