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