#include <bits/stdc++.h>
using namespace std;
int arr[100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    cin >> n;
    int evb = 0, odb = 0;
    for (i = 0; i < n; i++) {
      cin >> arr[i];
      if (i % 2 == 0 && arr[i] % 2 != 0) evb++;
      if (i % 2 != 0 && arr[i] % 2 == 0) odb++;
    }
    if (evb == odb)
      cout << evb << "\n";
    else
      cout << "-1\n";
  }
  return 0;
}
