#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
void solve() {
  int n;
  cin >> n;
  int cnte = 0, cnto = 0;
  for (int i = 0; i < n; ++i) {
    int num;
    cin >> num;
    cnte += (i % 2 == 0 && num % 2 == 1);
    cnto += (i % 2 == 1 && num % 2 == 0);
  }
  cout << (cnte == cnto ? cnte : -1) << endl;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
