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