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