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