#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int value, cnt = 0, cnt1 = 0;
    for (int i = 0; i < n; i++) {
      cin >> value;
      if (i % 2 == 0)
        if (value % 2 != 0) cnt++;
      if (i % 2 != 0)
        if (value % 2 == 0) cnt1++;
    }
    if (cnt != cnt1)
      cout << "-1" << endl;
    else
      cout << cnt << endl;
  }
  return 0;
}
