#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long N = 1e6 + 5;
long long n, first[N], a[N], b[N], m, trace[N], z, t, x, k, y;
string s, s1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    a[1] = 0;
    a[0] = 0;
    for (int i = 0; i <= n - 1; i++) {
      cin >> m;
      if ((i % 2 != 0) && (m % 2 == 0)) {
        a[0]++;
      } else if ((i % 2 == 0) && (m % 2 != 0)) {
        a[1]++;
      }
    }
    if (a[1] == a[0]) {
      cout << a[1];
      cout << endl;
    } else {
      cout << -1;
      cout << endl;
    }
  }
}
