#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, n;
  cin >> T;
  while (T--) {
    cin >> n;
    int a[n];
    int ctr = 0, str = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 == 1 && i % 2 == 0) ctr++;
      if (a[i] % 2 == 0 && i % 2 == 1) str++;
    }
    if (ctr != str) ctr = -1;
    cout << ctr << '\n';
  }
  return 0;
}
