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