#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const long long int mod = 1000000007;
int a[45];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    int noji = 0, noou = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 != i % 2) {
        if (i % 2 == 0)
          noji++;
        else
          noou++;
      }
    }
    if (noji != noou)
      cout << -1 << endl;
    else
      cout << noji << endl;
  }
}
