#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  for (int w = 1; w <= q; w++) {
    int n;
    cin >> n;
    int arr[n];
    int even = 0, odd = 0;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] % 2 == 0)
        even++;
      else
        odd++;
    }
    int count = 0;
    if (n % 2 == 1) {
      if (even == n / 2 + 1 && odd == n / 2) {
        for (int i = 0; i < n; i++) {
          if (i % 2 == 0 && arr[i] % 2 == 0)
            continue;
          else if (i % 2 == 1 && arr[i] % 2 == 1)
            continue;
          else
            count++;
        }
        cout << count / 2 << endl;
      } else {
        cout << "-1" << endl;
      }
    } else {
      if (even == n / 2 && odd == n / 2) {
        for (int i = 0; i < n; i++) {
          if (i % 2 == 0 && arr[i] % 2 == 0)
            continue;
          else if (i % 2 == 1 && arr[i] % 2 == 1)
            continue;
          else
            count++;
        }
        cout << count / 2 << endl;
      } else {
        cout << "-1" << endl;
      }
    }
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
      }
    }
  }
  return 0;
}
