#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int x;
    int bad_even = 0, bad_odd = 0;
    for (int i = int(0); i < int(n); ++i) {
      cin >> x;
      if (i % 2) {
        if (x % 2 == 0) bad_odd++;
      } else if (x % 2)
        bad_even++;
    }
    if (bad_odd == bad_even)
      cout << bad_odd << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
