#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, x;
  cin >> t;
  while (t--) {
    cin >> n;
    int odd = 0, ev = 0;
    for (int i = 0; i < n; i++) {
      cin >> x;
      if (i % 2 == 0 && x % 2 != 0)
        ev++;
      else if (i % 2 == 1 && x % 2 != 1)
        odd++;
    }
    if (odd == ev)
      cout << odd << endl;
    else
      cout << "-1" << endl;
  }
}
