#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n;
  while (t--) {
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int e = 0, o = 0, flag = 0;
    for (int i = 0; i < n; i++) {
      if ((i & 1) == (a[i] & 1)) {
        continue;
      } else {
        flag = flag + 1;
        if ((a[i] & 1) == 1) {
          o++;
        } else {
          e++;
        }
      }
    }
    if (flag == 0) {
      cout << "0" << endl;
    } else {
      if (e == o) {
        cout << e << endl;
      } else {
        cout << "-1" << endl;
      }
    }
  }
}
