#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> o, e;
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 != i % 2) {
        if (i % 2)
          o.push_back(i);
        else
          e.push_back(i);
      }
    }
    if (o.size() == e.size()) {
      cout << o.size() << "\n";
    } else {
      cout << -1 << "\n";
    }
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"
       << "\n";
  return 0;
}
