#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, ev, od;
  cin >> t;
  vector<int> v;
  while (t--) {
    cin >> n;
    ev = od = 0;
    v.resize(n + 1);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (i % 2 == 0 && v[i] % 2 == 1)
        ev++;
      else if (i % 2 == 1 && v[i] % 2 == 0)
        od++;
    }
    if (ev != od)
      cout << "-1\n";
    else
      cout << ev << endl;
    v.clear();
  }
  return 0;
}
