#include <bits/stdc++.h>
using namespace std;
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    int n, a[1000];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int odd = 0, even = 0;
    for (int i = 0; i < n; i++) {
      if ((i & 1) && (a[i] & 1) == 0)
        even++;
      else if ((i & 1) == 0 && (a[i] & 1))
        odd++;
    }
    cout << (odd != even ? -1 : even) << endl;
    ;
  }
}
