#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int eseti = 0, eunset = 0, os = 0, ou = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i % 2 == 0) {
        if (a[i] % 2 == 0) {
          eseti++;
        } else {
          ou++;
        }
      } else if (i % 2 == 1) {
        if (a[i] % 2 == 0) {
          eunset++;
        } else {
          os++;
        }
      }
    }
    if (n == 1 && ou == 1) {
      cout << "-1\n";
      continue;
    } else if (n == 1 && eseti == 1) {
      cout << 0 << "\n";
      continue;
    }
    if (ou == 0 && eunset == 0) {
      cout << 0 << "\n";
    } else if (eunset == ou) {
      cout << eunset << "\n";
    } else {
      cout << "-1\n";
    }
  }
  return 0;
}
