#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    int ar[n];
    int c = 0, c1 = 0;
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
      if (i % 2 == 0 && ar[i] % 2 == 1) {
        c++;
      } else if (i % 2 == 1 && ar[i] % 2 == 0) {
        c1++;
      }
    }
    if (c == c1) {
      cout << c << "\n";
    } else {
      cout << -1 << "\n";
    }
  }
}
