#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int c = 0;
    int d = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i % 2 == 0) {
        if (a[i] % 2 != 0) {
          c++;
        }
      }
      if (i % 2 != 0) {
        if (a[i] % 2 == 0) {
          d++;
        }
      }
    }
    if (c == d) {
      cout << c << endl;
    }
    if (c != d) {
      cout << "-1" << endl;
    }
  }
  return 0;
}
