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