#include <bits/stdc++.h>
using namespace std;
template <typename T>
void max_self(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void min_self(T &x, T y) {
  x = min(x, y);
}
long long modExpo(long long a, long long b, long long c) {
  a = a % c;
  if (b == 0)
    return 1;
  else if ((b % 2) == 0)
    return modExpo((a * a) % c, b / 2, c) % c;
  else
    return (a * (modExpo((a * a) % c, b / 2, c) % c)) % c;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    for (long long i = 0; i < n; ++i) cin >> arr[i];
    vector<long long> odd;
    vector<long long> even;
    for (long long i = 0; i < n; ++i) {
      if (i & 1) {
        if (arr[i] % 2 == 0) odd.push_back(i);
      } else {
        if (arr[i] % 2 != 0) even.push_back(i);
      }
    }
    long long o = (long long)odd.size(), e = (long long)even.size();
    if (o == e)
      cout << o << "\n";
    else
      cout << "-1\n";
  }
  return 0;
}
