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