#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n);
    int odd = 0;
    int even = 0;
    int prob = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] % 2 == 1) {
        ++odd;
        if (i % 2 == 0) {
          ++prob;
        }
      } else {
        ++even;
        if (i % 2 == 1) {
          ++prob;
        }
      }
    }
    if (odd != n / 2) {
      cout << "-1\n";
    } else {
      cout << prob / 2 << "\n";
    }
  }
  return 0;
}
