description: <image>
  
  William has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer k is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer k)
  
    1. add number k to both a and b, or 
    2. add number k to a and subtract k from b, or 
    3. add number k to b and subtract k from a. 
  
  
  
  Note that after performing operations, numbers a and b may become negative as well.
  
  William wants to find out the minimal number of operations he would have to perform to make a equal to his favorite number c and b equal to his second favorite number d.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.
  
  The only line of each test case contains two integers c and d (0 ≤ c, d ≤ 10^9), which are William's favorite numbers and which he wants a and b to be transformed into.
  
  Output
  
  For each test case output a single number, which is the minimal number of operations which William would have to perform to make a equal to c and b equal to d, or -1 if it is impossible to achieve this using the described operations.
  
  Example
  
  Input
  
  
  6
  1 2
  3 5
  5 3
  6 6
  8 0
  0 0
  
  
  Output
  
  
  -1
  2
  2
  1
  2
  0
  
  Note
  
  Let us demonstrate one of the suboptimal ways of getting a pair (3, 5):
  
    * Using an operation of the first type with k=1, the current pair would be equal to (1, 1). 
    * Using an operation of the third type with k=8, the current pair would be equal to (-7, 9). 
    * Using an operation of the second type with k=7, the current pair would be equal to (0, 2). 
    * Using an operation of the first type with k=3, the current pair would be equal to (3, 5). 
solution: import java.util.*;
  import java.io.*;
  public class Main {
      static Scanner in =new Scanner(System.in);
      static final Random random=new Random();
      static int mod=1000_000_007;
      static int []rank;
      static List<List<Integer>>adj;
      public static void main(String[] args) {
          int tt=in.nextInt();//in.nextLine();
             outer:while(tt-->0) {
                 int c=in.nextInt();int d=in.nextInt();
                 if(c==0 && d==0){System.out.println(0);continue outer;}
                 if(c==d){System.out.println(1);continue outer;}
                 
                 if((Math.abs(c-d))%2==0){System.out.println(2);continue outer;}
                 System.out.println(-1);
         }
      }
      
      static long sum(long n){
          long res=0;
          while(n>0){
              res+=(n%10);n/=10;
          }
          return res;
      }
      static void uf (int[] root, int v1, int v2) {
              int rootP = find(v1,root);
              int rootQ = find(v2,root);
              if (rootP == rootQ) return;
              if (rank[rootQ] > rank[rootP]) {
                  root[rootP] = rootQ;
                  rank[rootQ]+=rank[rootP];
                  rank[rootP]=0;
              }
              else {
                  root[rootQ] = rootP;
                  rank[rootP]+=rank[rootQ];
                  rank[rootQ]=0;
              }
      }
      static int find(int p,int [] root) {
          	while (p != root[p]) {
                 root[p] =root[root[p]];
                  p = root[p];
              }
              return p;
          }
      static int nCr(int n,int r,int p){
          if (r == 0) return 1; 
          if(r==1)return n;
          return ((int)fact(n)*modInverse((int)fact(r),p)%p * modInverse((int)fact(n-r),p) % p)%p; 
      }
      static int modInverse(int n, int p){ 
          return power(n, p-2, p); 
      } 
      static int power(int x,int y,int p){ 
          int res = 1;
          x= x % p;
          while (y>0){
              if (y%2==1) 
                  res= (res*x)% p;
              y= y >> 1;
              x= (x*x)% p; 
          }
          return res; 
      } 
      static void seive(){
          int num=1000001;
          boolean[] prime = new boolean[num];
          Arrays.fill(prime,true);
          for (int i=2; i*i<=num; i++) {
              if(prime[i] == true) {
                  for(int j=i*i; j<num; j=j+i) {
                     prime[j]=false;
                  }
              }
          }
      }
      static long[]readAr(int n) {
          long[] a=new long[(int)n];
          for (int i=0; i<n; i++) {a[i]=in.nextLong();}
          return a;
  	}
      static int[]readA1r(int n) {
          int[] a=new int[(int)n];
          for (int i=0; i<n; i++) {a[i]=in.nextInt();}
          return a;
  	}
      static int fact(int k){
          long[]f=new long[10001];f[1]=1;
          for(int i=2;i<10001;i++){
              f[i]=(i*f[i-1]% mod);
          }
          return (int)f[k];
      }
  	static void ruffleSort(int[] a) {
  		int n=a.length;
  		for (int i=0; i<n; i++) {
  			int oi=random.nextInt(n), temp=a[oi];
  			a[oi]=a[i]; a[i]=temp;
  		}
  		Arrays.sort(a);
  	}
  	static void reverse(int []a){
          int n= a.length;
          for(int i=0;i<n/2;i++){
              int temp=a[i];
              a[i]=a[n-i-1];
              a[n-i-1]=temp;
          }
          //debug(a);
  	}
  	static void debug(int []a) {
          for (int i=0; i<a.length;i++) System.out.print(a[i]+" ");
          System.out.println();
  	}
  	static void print(List<Integer>s) {
          for(int x:s) System.out.print(x+",");
          System.out.println();
  	}
  	static long gcd(long a, long b) {
          return (b==0) ? a : gcd(b, a % b);
  	}
      static long find_max(long []a){
          long m=Integer.MIN_VALUE;
          for(long x:a)m=Math.max(x,m);
          return m;
      }
      static int find_min(int []a){
          int m=Integer.MAX_VALUE;
          for(int x:a)m=Math.min(x,m);
          return m;
      }
  }