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