#include <bits/stdc++.h>
using namespace std;
int t, n;
int a[1005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    int s = 0;
    int x = 0;
    int y = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 != i % 2) s++;
      if (a[i] % 2 == 0)
        x++;
      else
        y++;
    }
    int k = (n + 1) / 2;
    if (s % 2 || x != k || y != n - k) {
      cout << "-1" << endl;
      continue;
    }
    cout << s / 2 << endl;
  }
  return 0;
}
