#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    long long one = 0, zero = 0;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      if (i % 2 == 0) {
        if (arr[i] % 2 != 0) {
          one++;
        }
      } else if (i % 2 == 1) {
        if (arr[i] % 2 != 1) {
          zero++;
        }
      }
    }
    if (one != zero) {
      cout << "-1" << endl;
    } else {
      cout << min(one, zero) << endl;
    }
  }
}
