#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int z = 0; z < t; z++) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int even = 0, odd = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 != 0 && i % 2 == 0) even++;
      if (a[i] % 2 == 0 && i % 2 != 0) odd++;
    }
    if (even == odd)
      cout << even << endl;
    else
      cout << -1 << endl;
  }
}
