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