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