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