#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 ew = 0, ow = 0;
    for (int i = 0; i < n; i += 2) {
      if (arr[i] % 2 == 1) ew++;
    }
    for (int i = 1; i < n; i += 2) {
      if (arr[i] % 2 == 0) ow++;
    }
    if (ow != ew)
      cout << -1 << endl;
    else
      cout << ew << endl;
  }
}
