#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.fr >> a.sc;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.fr << " " << a.sc;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const double PI = acos(-1.0);
const double eps = 1e-9;
const long long int mod = 1e9 + 7;
const long long int inf = 1LL << 30;
const int MAXN = 1e5 + 5;
const int N = 2e5 + 5;
long long int max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int min(long long int a, long long int b) {
  if (a < b)
    return a;
  else
    return b;
}
vector<long long int> adj[200001];
long long int par[200001];
bool vis[200001], on_cycle[200001];
vector<long long int> cycle;
bool is_cycle = false;
long long int res;
void solve() {
  long long int n, i, j, x;
  cin >> n;
  long long int cte = 0;
  long long int cto = 0;
  vector<long long int> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i += 2) {
    if (a[i] % 2 == 1) {
      cte++;
    }
  }
  for (i = 1; i < n; i += 2) {
    if (a[i] % 2 == 0) {
      cto++;
    }
  }
  if (cte != cto) {
    cout << -1 << "\n";
  } else {
    cout << cte << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
