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