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: /*
      AUTH -> krishna-3249
      DATE -> 8/29/21
      TIME -> 8:35 PM
  */
  
  /*
      Simple can be harder than complex.
      Body, mind and spirit.
      Strive for progress, not perfection.
  */
  
  import java.lang.*;
  import java.io.*;
  import java.util.*;
  
  public class Main {
  
      private static final long MOD = 1_000_000_000 + 7;
  
      private long power(long base, long exponent) {
          long res = 1;
          while (exponent > 0) {
              if ((exponent & 1) == 1) {
                  res = (res * base) % MOD;
                  exponent--;
              } else {
                  base = (base * base) % MOD;
                  exponent = exponent >> 1;
              }
          }
          return res;
      }
  
      private long inverseMod(long number) {
          return power(number, MOD - 2);
      }
  
      private int gcd(int a, int b) {
          if (b == 0) {
              return a;
          }
          return gcd(b, a % b);
      }
  
      private long gcd(long a, long b) {
          if (b == 0) {
              return a;
          }
          return gcd(b, a % b);
      }
  
      public void solve(Read input, Write output) throws Exception {
          int cases = input.readInt();
          while (cases-- > 0) {
              long c = input.readLong();
              long d = input.readLong();
              if (c==0 && d==0) {
                  output.printLine("0");
              } else if (c==d) {
                  output.printLine("1");
              } else if ((c+d)%2l==0) {
                  output.printLine("2");
              } else {
                  output.printLine("-1");
              }
          }
      }
  
      public static void main(String[] args) throws Exception {
          Read input = new Read();
          Write output = new Write();
          Main D = new Main();
          D.solve(input, output);
          output.flush();
          output.close();
      }
  
      // java fast io reader and writer
      // taken from various sources and customized
  
      static class Read {
  
          private byte[] buffer = new byte[10 * 1024];
          private int index;
          private InputStream input_stream;
          private int total;
  
          public Read() {
              input_stream = System.in;
          }
  
          public int read() throws IOException {
              if (total < 0)
                  throw new InputMismatchException();
              if (index >= total) {
                  index = 0;
                  total = input_stream.read(buffer);
                  if (total <= 0)
                      return -1;
              }
              return buffer[index++];
          }
  
          public long readLong() throws IOException {
              long number = 0;
              int n = read();
              while (isWhiteSpace(n))
                  n = read();
              long neg = 1l;
              if (n == '-') {
                  neg = -1l;
                  n = read();
              }
              while (!isWhiteSpace(n)) {
                  if (n >= '0' && n <= '9') {
                      number *= 10l;
                      number += (long) (n - '0');
                      n = read();
                  } else throw new InputMismatchException();
              }
              return neg * number;
          }
  
          public int readInt() throws IOException {
              int integer = 0;
              int n = read();
              while (isWhiteSpace(n))
                  n = read();
              int neg = 1;
              if (n == '-') {
                  neg = -1;
                  n = read();
              }
              while (!isWhiteSpace(n)) {
                  if (n >= '0' && n <= '9') {
                      integer *= 10;
                      integer += n - '0';
                      n = read();
                  } else throw new InputMismatchException();
              }
              return neg * integer;
          }
  
          public double readDouble() throws IOException {
              double doub = 0;
              int n = read();
              while (isWhiteSpace(n))
                  n = read();
              int neg = 1;
              if (n == '-') {
                  neg = -1;
                  n = read();
              }
              while (!isWhiteSpace(n) && n != '.') {
                  if (n >= '0' && n <= '9') {
                      doub *= 10;
                      doub += n - '0';
                      n = read();
                  } else throw new InputMismatchException();
              }
  
              if (n == '.') {
                  n = read();
                  double temp = 1;
                  while (!isWhiteSpace(n)) {
                      if (n >= '0' && n <= '9') {
                          temp /= 10;
                          doub += (n - '0') * temp;
                          n = read();
                      } else throw new InputMismatchException();
                  }
              }
              return doub * neg;
          }
  
          public String readString() throws IOException {
              StringBuilder sb = new StringBuilder();
              int n = read();
              while (isWhiteSpace(n))
                  n = read();
              while (!isWhiteSpace(n)) {
                  sb.append((char) n);
                  n = read();
              }
              return sb.toString();
          }
  
          public List<Double> readDoubleList(int size) throws IOException {
              List<Double> res = new ArrayList<>();
              for (int i = 0; i < size; i++) {
                  res.add(this.readDouble());
              }
              return res;
          }
  
          public double[] readDoubleArray(int size) throws IOException {
              double[] res = new double[size];
              for (int i = 0; i < size; i++) {
                  res[i] = this.readDouble();
              }
              return res;
          }
  
          public List<String> readStringList(int size) throws IOException {
              List<String> res = new ArrayList<>();
              for (int i = 0; i < size; i++) {
                  res.add(this.readString());
              }
              return res;
          }
  
          public String[] readStringArray(int size) throws IOException {
              String[] res = new String[size];
              for (int i = 0; i < size; i++) {
                  res[i] = this.readString();
              }
              return res;
          }
  
          public List<Integer> readIntList(int size) throws IOException {
              List<Integer> res = new ArrayList<>();
              for (int i = 0; i < size; i++) {
                  res.add(this.readInt());
              }
              return res;
          }
  
          public List<Long> readLongList(int size) throws IOException {
              List<Long> res = new ArrayList<>();
              for (int i = 0; i < size; i++) {
                  res.add(this.readLong());
              }
              return res;
          }
  
          public int[] readIntArray(int size) throws IOException {
              int[] res = new int[size];
              for (int i = 0; i < size; i++) {
                  res[i] = this.readInt();
              }
              return res;
          }
  
          public long[] readLongArray(int size) throws IOException {
              long[] res = new long[size];
              for (int i = 0; i < size; i++) {
                  res[i] = this.readLong();
              }
              return res;
          }
  
          private boolean isWhiteSpace(int n) {
              if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                  return true;
              return false;
          }
      }
  
      static class Write {
  
          private final BufferedWriter bw;
  
          public Write() {
              bw = new BufferedWriter(new OutputStreamWriter(System.out));
          }
  
          public void print(Object str) throws IOException {
              bw.append(str + "");
          }
  
          public void printLine(Object str) throws IOException {
              print(str);
              bw.append("\n");
          }
  
          public void close() throws IOException {
              bw.close();
          }
  
          public void flush() throws IOException {
              bw.flush();
          }
      }
  }