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