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