#include <bits/stdc++.h>
using namespace std;
int main() {
  int count = 0;
  int T;
  cin >> T;
  while (count++ < T) {
    int n, TABLE[40];
    int nbIndexRetImpair = 0, nbIndexRetPair = 0;
    cin >> n;
    for (int pop = 0; pop < n; pop++) cin >> TABLE[pop];
    for (int pop = 0; pop < n; pop++) {
      if (!(pop % 2) && TABLE[pop] % 2) {
        ++nbIndexRetPair;
        continue;
      }
      if (pop % 2 && !(TABLE[pop] % 2)) {
        ++nbIndexRetImpair;
        continue;
      }
    }
    if (nbIndexRetPair == nbIndexRetImpair)
      cout << nbIndexRetImpair << endl;
    else {
      cout << "-1" << endl;
    }
  }
  return 0;
}
