#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    int odd = 0, even = 0;
    int min = 0;
    cin >> n;
    int arr[n];
    for (i = 0; i < n; i++) cin >> arr[i];
    for (i = 0; i < n; i++) {
      if (arr[i] % 2 == i % 2)
        continue;
      else if (arr[i] % 2 == 0)
        even++;
      else
        odd++;
    }
    if (even == odd)
      cout << even << endl;
    else
      cout << "-1" << endl;
  }
}
