#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a[10001], n;
    cin >> n;
    int cnt = 0, cnt1 = 0, cnt2 = 0, b;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 != 0 && i % 2 == 0) {
        cnt1++;
      }
      if (a[i] % 2 == 0 && i % 2 != 0) {
        cnt2++;
      }
    }
    if (cnt1 == cnt2)
      cout << cnt1 << endl;
    else {
      cout << "-1" << endl;
    }
  }
}
