#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    int n, even = 0, odd = 0, i, mis = 0;
    cin >> n;
    int a[n];
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 == 0)
        even++;
      else
        odd++;
      if (a[i] % 2 != i % 2) mis++;
    }
    if (n % 2 == 0 && even == odd) {
      cout << mis / 2 << endl;
    } else if (n % 2 == 1 && even == odd + 1) {
      cout << mis / 2 << endl;
    } else
      cout << -1 << endl;
  }
}
