#include <bits/stdc++.h>
int main() {
  int t, n, *arr, i, a, odd, even;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    arr = (int*)malloc(n * sizeof(int));
    for (i = 0; i < n; i++) scanf("%d", &arr[i]);
    even = 0;
    odd = 0;
    for (i = 0; i < n; i++) {
      if (arr[i] % 2 == 0)
        even++;
      else
        odd++;
    }
    a = 0;
    if (n % 2 == 0) {
      if (even == odd) {
        for (i = 0; i < n; i++) {
          if ((i % 2) != (arr[i] % 2)) a++;
        }
        printf("%d\n", a / 2);
      } else
        printf("%d\n", -1);
    } else {
      if (odd == (even - 1)) {
        for (i = 0; i < n; i++) {
          if ((i % 2) != (arr[i] % 2)) a++;
        }
        printf("%d\n", a / 2);
      } else
        printf("%d\n", -1);
    }
  }
  return 0;
}
