#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  while (a--) {
    int b;
    cin >> b;
    int arr[b];
    for (int j = 0; j < b; j++) cin >> arr[j];
    int cont = 0;
    for (int j = 0; j < b - 1; j++) {
      for (int k = j + 1; k < b; k++) {
        if (arr[k] % 2 != 0 && k % 2 == 0) {
          if (arr[j] % 2 == 0 && j % 2 != 0) {
            swap(arr[j], arr[k]);
            cont++;
            break;
          }
        } else if (arr[k] % 2 == 0 && k % 2 != 0) {
          if (arr[j] % 2 != 0 && j % 2 == 0) {
            swap(arr[j], arr[k]);
            cont++;
            break;
          }
        }
      }
    }
    int flag = 0;
    for (int j = 0; j < b; j++) {
      if (arr[j] % 2 == (j) % 2)
        continue;
      else {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      cout << "-1\n";
    else
      cout << cont << "\n";
  }
}
