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