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 collections
  # import random
  # import math
  # import itertools
  # import math
  # import math
  #import bisect
  # from collections import defaultdict
  # import itertools
  # from sys import stdin, stdout
  # import math
  # import math
  # import bisect
  # import bisect
  # import collections
  # import itertools
  # import math
  # import collections
  # import itertools
  # import math
  import bisect
  import collections
  import math
  import sys
  
  # import operator
  # from decimal import Decimal
  
  # sys.setrecursionlimit(10**6)
  
  
  
  
  
  p2D = lambda x: print(*x, sep="\n")
  
  
  def II(): return int(sys.stdin.buffer.readline())
  
  
  def MI(): return map(int, sys.stdin.buffer.readline().split())
  
  
  def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
  
  
  def LLI(rows_number): return [LI() for _ in range(rows_number)]
  
  
  def BI(): return sys.stdin.buffer.readline().rstrip()
  
  
  def SI(): return sys.stdin.buffer.readline().rstrip().decode()
  
  
  def li(): return [int(i) for i in input().split()]
  
  
  def lli(rows): return [li() for _ in range(rows)]
  
  
  def si(): return input()
  
  
  def ii(): return int(input())
  
  
  def ins(): return input().split()
  
  
  # mod = 10**9+7
  # fval = [1]
  # for i in range(1,200001):
  #     x = (fval[-1]*i)%mod
  #     fval.append(x)
  #
  # ifac = [1]*(200001)
  # ifac[200000] = pow(fval[200000], -1, mod)
  # for i in range(200000-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%mod
  # _________________ For taking Input from the Text Files __________________
  # import os.path
  #
  # if (os.path.exists('input.txt')):
  #     sys.stdin = open("input.txt", "r")
  #     sys.stdout = open("output.txt", "w")
  #     sys.stderr = open("error.txt", "w")
  
  def drank(d, processing, da, rank):
      tmp = 10 ** 9
      if len(d[da]) == 1:
          return 1
      for di in d[da]:
          if processing[di - 1] == 0:
              processing[di - 1] = 1
              tmp = min(tmp, drank(d, processing, di, rank))
              processing[di - 1] = 0
      rank[da - 1] = tmp + 1
      return tmp + 1
  
  
  
  def binary_search(n, a):
      l = len(a)
      low = 0
      high = l-1
      while high>=low:
          mid = (high+low)//2
          if a[mid] == n:
              return mid
          elif a[mid]>n:
              high = mid-1
          else:
              low = mid+1
      return -1
  
  is_prime = [True]*(10**6+1)
  def primeseive(n):
      is_prime[0] = is_prime[1] = False
      i = 2
      while i*i<=n:
          if is_prime[i] == True:
              for j in range(i*i,n+1,i):
                  is_prime[j] = False
          i+=1
  
  
  def solve():
      a, s = si().split(' ')
      i = 0
      j = 0
      la = len(a)
      ls = len(s)
      a = a[::-1]
      s = s[::-1]
      #print(s)
      #print(a)
      ans = ''
      while i<la:
          if j>=ls:
              return -1
          if a[i]<=s[j]:
              ans+= str(int(s[j])-int(a[i]))
              i+=1
              j+=1
          else:
              if j+1<ls and s[j+1]=='1':
                  ans += str(int('1'+s[j])- int(a[i]))
                  i+=1
                  j+=2
              else:
                  return -1
      if j!=ls:
          ans += s[j:]
      return (ans.rstrip('0'))[::-1]
  def main():
      #primeseive(10**6)
      #print(is_prime)
  
      for _ in range(ii()):
          #print(solve(), flush=True)
          sys.stdout.write(str(solve()) + "\n")
      #print(solve())
  
      #     z += str(ans) + '\n'
      # print(len(ans), ' '.join(map(str, ans)), sep='\n')
      # stdout.write(z)
  
  
  # for interactive problems
  # print("? {} {}".format(l,m), flush=True)
  # or print this after each print statement
  # sys.stdout.flush()
  
  
  if __name__ == "__main__":
      main()