#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, x, y, b, c, z1, z2, z3;
  string s;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n];
    x = 0, y = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (i % 2 == 0 && a[i] % 2 != 0)
        x++;
      else if (i % 2 != 0 && a[i] % 2 == 0) {
        y++;
      }
    }
    if (x == y) {
      cout << x << endl;
    } else {
      cout << "-1" << endl;
    }
  }
}
