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