#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, A[41], Cnt1 = 0, Cnt2 = 0;
    cin >> n;
    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 << "\n";
    else
      cout << -1 << "\n";
  }
}
