#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long MOD = 1e9 + 7, MAXN = 51;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], cnt[2] = {};
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      if (i % 2 != a[i] % 2) cnt[a[i] % 2]++;
    }
    if (cnt[0] != cnt[1])
      cout << -1 << "\n";
    else {
      cout << cnt[0] << "\n";
    }
  }
}
