#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int odcount = 0;
    int evcount = 0;
    vector<int> num(n);
    for (int i = 0; i < n; i++) {
      cin >> num[i];
    }
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0 && num[i] % 2 != 0) {
        odcount++;
      } else if (i % 2 != 0 && num[i] % 2 == 0) {
        evcount++;
      }
    }
    int count = odcount + evcount;
    if (count == 0) {
      cout << count << endl;
    } else if (count % 2 != 0 || odcount != evcount) {
      cout << "-1" << endl;
    } else {
      cout << (count / 2) << endl;
    }
  }
  return 0;
}
