#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m, p, x, b, c, k;
    cin >> n;
    vector<long long int> a(n);
    for (long long int i = 0; i < n; i++) cin >> a[i];
    long long int o = 0;
    for (int i = 0; i < n; i += 2) {
      if (a[i] & 1) o++;
    }
    long long int e = 0;
    for (int i = 1; i < n; i += 2) {
      if (a[i] % 2 == 0) e++;
    }
    if (e != o)
      cout << "-1" << endl;
    else
      cout << e << endl;
  }
}
