#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 3e18;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, eo = 0, oe = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      if (a[i] % 2 == 0 && i & 1)
        eo++;
      else if (a[i] & 1 && i % 2 == 0)
        oe++;
    }
    if (eo == oe)
      printf("%d\n", oe);
    else
      printf("%d\n", -1);
  }
  return 0;
}
