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.util.*;
  import java.io.*;
  
  public class Practice {
  	static boolean multipleTC = true;
  	FastReader in;
  	PrintWriter out;
  
  	static int mod = (int) (1e9 + 7);
  	int mod2 = 998244353;
  	int parent[];
  	int rank[];
  
  	public static void main(String[] args) throws Exception {
  		new Practice().run();
  	}
  
  	void run() throws Exception {
  		in = new FastReader();
  		out = new PrintWriter(System.out);
  		int T = (multipleTC) ? ni() : 1;
  		pre();
  		for (int t = 1; t <= T; t++)
  			solve(t);
  		out.flush();
  		out.close();
  	}
  
  	void pre() throws Exception {
  	}
  
  	void solve(int TC) throws Exception {
  		long a = nl();
  		long s = nl();
  		StringBuilder sb = new StringBuilder();
  		String aa = Long.toString(a);
  		String ss = Long.toString(s);
  		if(aa.equals(ss)) {
  			pn("0");
  			return;
  		}
  		int p1 = aa.length() - 1;
  		int p2 = ss.length() - 1;
  		while (p2 >= 0) {
  			if (p2 < 0) {
  				pn("-1");
  				return;
  			}
  			int digit = 0;
  			if (p1 >= 0) {
  				digit = aa.charAt(p1) - '0';
  			}
  
  			int sDigit = ss.charAt(p2) - '0';
  			p1--;
  			p2--;
  			if (digit > sDigit) {
  				if (p2 >= 0) {
  					sDigit = sDigit + (ss.charAt(p2) - '0') * 10;
  					p2--;
  				} else {
  					pn("-1");
  					return;
  				}
  
  			}
  			sb.insert(0, (sDigit - digit) + "");
  		}
  		if (p1 >= 0) {
  			pn("-1");
  		} else {
  			int i = 0;
  			while (i < sb.length() && sb.charAt(i) == '0') {
  				i++;
  			}
  			String ans = sb.substring(i, sb.length());
  
  			if (validate(aa, ans, ss)) {
  				pn(ans);
  			} else {
  				pn("-1");
  			}
  		}
  
  	}
  
  	boolean validate(String a, String b, String sum) {
  		StringBuilder sb = new StringBuilder();
  		int p1 = a.length()-1;
  		int p2 = b.length()-1;
  		while (p1 >= 0 || p2 >= 0) {
  			int d1 = 0;
  			int d2 = 0;
  			if (p1 >= 0) {
  				d1 = a.charAt(p1) - '0';
  			}
  			if (p2 >= 0) {
  				d2 = b.charAt(p2) - '0';
  			}
  			p1--;
  			p2--;
  			sb.insert(0, d1 + d2);
  		}
  		return sb.toString().equals(sum);
  	}
  
  	void union(int u, int v, int rank[], int parent[]) {
  		u = findParent(u, parent);
  		v = findParent(v, parent);
  		if (rank[u] > rank[v]) {
  			parent[v] = u;
  		} else if (rank[u] < rank[v]) {
  			parent[u] = v;
  		} else {
  			parent[v] = u;
  			rank[u]++;
  		}
  	}
  
  	int findParent(int v, int parent[]) {
  		if (v == parent[v])
  			return v;
  		return parent[v] = findParent(parent[v], parent);
  	}
  
  	StringBuilder printArr(int arr[]) {
  		StringBuilder sb = new StringBuilder();
  		int n = arr.length;
  		for (int i = 0; i < n; i++) {
  			sb.append(arr[i] + " ");
  		}
  		return sb;
  	}
  
  	StringBuilder printArr(long arr[]) {
  		StringBuilder sb = new StringBuilder();
  		int n = arr.length;
  		for (int i = 0; i < n; i++) {
  			sb.append(arr[i] + " ");
  		}
  		return sb;
  	}
  
  	class pair {
  		int x, y;
  
  		pair(int x, int y) {
  			this.x = x;
  			this.y = y;
  		}
  
  		@Override
  		public String toString() {
  			return " " + x + ", " + y + "]";
  		}
  
  	}
  
  	class pairL {
  		long x, y;
  
  		pairL(long x, long y) {
  			this.x = x;
  			this.y = y;
  		}
  
  		@Override
  		public String toString() {
  			return " " + x + ", " + y + "]";
  		}
  
  	}
  
  	boolean isSorted(int arr[]) {
  		for (int i = 0; i < arr.length - 1; i++) {
  			if (arr[i] > arr[i + 1]) {
  				return false;
  			}
  		}
  		return true;
  	}
  
  	void swap(int arr[], int x, int y) {
  		int t = arr[x];
  		arr[x] = arr[y];
  		arr[y] = t;
  	}
  
  	static int bitCount(int x) {
  		return x == 0 ? 0 : (1 + bitCount(x & (x - 1)));
  	}
  
  	void sort(long arr[]) {
  		ArrayList<Long> list = new ArrayList<>();
  		for (int i = 0; i < arr.length; i++)
  			list.add(arr[i]);
  		Collections.sort(list);
  		for (int i = 0; i < arr.length; i++)
  			arr[i] = list.get(i);
  	}
  
  	static void dbg(Object... o) {
  		System.err.println(Arrays.deepToString(o));
  	}
  
  	ArrayList<Integer> primeFactorization(int n) {
  		ArrayList<Integer> factorization = new ArrayList<>();
  		while (n % 2 == 0) {
  			factorization.add(2);
  			n /= 2;
  		}
  		for (int d = 3; d * d <= n; d += 2) {
  			while (n % d == 0) {
  				factorization.add(d);
  				n /= d;
  			}
  		}
  		if (n > 1)
  			factorization.add(n);
  		return factorization;
  	}
  
  	private ArrayList<Integer> getPrimes(int n) {
  		boolean sieve[] = new boolean[n + 1];
  		sieve[0] = sieve[1] = true;
  		for (int i = 2; i * i <= n; i++) {
  			if (!sieve[i]) {
  				for (int j = i * i; j <= n; j += i) {
  					sieve[j] = true;
  				}
  			}
  		}
  		ArrayList<Integer> primes = new ArrayList<>();
  		for (int i = 2; i <= n; i++) {
  			if (!sieve[i]) {
  				primes.add(i);
  			}
  		}
  		return primes;
  	}
  
  	public static boolean isPrime(long n) {
  		if (n < 2)
  			return false;
  		if (n == 2 || n == 3)
  			return true;
  		if (n % 2 == 0 || n % 3 == 0)
  			return false;
  		long sqrtN = (long) Math.sqrt(n) + 1;
  		for (long i = 6L; i <= sqrtN; i += 6) {
  			if (n % (i - 1) == 0 || n % (i + 1) == 0)
  				return false;
  		}
  		return true;
  	}
  
  	public static long gcd(long a, long b) {
  		if (a > b)
  			a = (a + b) - (b = a);
  		if (a == 0L)
  			return b;
  		return gcd(b % a, a);
  	}
  
  	public long binaryExpo(long base, long exp) {
  		long res = 1;
  		while (exp > 0) {
  			if ((exp & 1) == 1)
  				res = res * base;
  			base = base * base;
  			exp >>= 1;
  		}
  		return res;
  	}
  
  	public long pow(long base, long exp, long MOD) {
  		base %= MOD;
  		long res = 1;
  		while (exp > 0) {
  			if ((exp & 1) == 1)
  				res = res * base % MOD;
  			base = base * base % MOD;
  			exp >>= 1;
  		}
  		return res;
  	}
  
  	public static long totient(long n) {
  		long result = n;
  		for (int p = 2; p * p <= n; ++p)
  			if (n % p == 0) {
  				while (n % p == 0)
  					n /= p;
  				result -= result / p;
  			}
  		if (n > 1)
  			result -= result / n;
  		return result;
  	}
  
  	int bit(long n) {
  		return (n == 0) ? 0 : (1 + bit(n & (n - 1)));
  	}
  
  	public long max(long... arr) {
  		long max = arr[0];
  		for (long itr : arr)
  			max = Math.max(max, itr);
  		return max;
  	}
  
  	public int max(int... arr) {
  		int max = arr[0];
  		for (int itr : arr)
  			max = Math.max(max, itr);
  		return max;
  	}
  
  	public long min(long... arr) {
  		long min = arr[0];
  		for (long itr : arr)
  			min = Math.min(min, itr);
  		return min;
  	}
  
  	public int min(int... arr) {
  		int min = arr[0];
  		for (int itr : arr)
  			min = Math.min(min, itr);
  		return min;
  	}
  
  	public long sum(long... arr) {
  		long sum = 0;
  		for (long itr : arr)
  			sum += itr;
  		return sum;
  	}
  
  	public long sum(int... arr) {
  		long sum = 0;
  		for (int itr : arr)
  			sum += itr;
  		return sum;
  	}
  
  	void p(Object o) {
  		out.print(o);
  	}
  
  	void pn(Object o) {
  		out.println(o);
  	}
  
  	void pni(Object o) {
  		out.println(o);
  		out.flush();
  	}
  
  	String n() throws Exception {
  		return in.next();
  	}
  
  	String nln() throws Exception {
  		return in.nextLine();
  	}
  
  	int ni() throws Exception {
  		return Integer.parseInt(in.next());
  	}
  
  	long nl() throws Exception {
  		return Long.parseLong(in.next());
  	}
  
  	long[] readArr(int n) throws Exception {
  		long arr[] = new long[n];
  		for (int i = 0; i < n; i++) {
  			arr[i] = nl();
  		}
  		return arr;
  	}
  
  	double nd() throws Exception {
  		return Double.parseDouble(in.next());
  	}
  
  	class FastReader {
  		BufferedReader br;
  		StringTokenizer st;
  
  		public FastReader() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
  
  		public FastReader(String s) throws Exception {
  			br = new BufferedReader(new FileReader(s));
  		}
  
  		String next() throws Exception {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					throw new Exception(e.toString());
  				}
  			}
  			return st.nextToken();
  		}
  
  		String nextLine() throws Exception {
  			String str = "";
  			try {
  				str = br.readLine();
  			} catch (IOException e) {
  				throw new Exception(e.toString());
  			}
  			return str;
  		}
  	}
  }