#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    map<int, int> mp;
    int e = 0, o = 0;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if ((i % 2) != (a[i] % 2)) mp[a[i] % 2]++;
    }
    if (mp[0] == mp[1]) {
      cout << mp[0] << endl;
    } else
      cout << -1 << endl;
  }
  return 0;
}
