#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, arr[40], o = 0, e = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
      cin >> arr[i], o += (arr[i] & 1), e += !(arr[i] & 1);
    if (o != n / 2) {
      cout << "-1\n";
      continue;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += (arr[i] % 2 != i % 2);
    cout << ans / 2 << '\n';
  }
  return 0;
}
