#include <bits/stdc++.h>
using namespace std;
void solve(void) {
  long long int i, j, k, n, m, ct = 0, t, ans = 0;
  cin >> n;
  long long int odd = 0, even = 0;
  long long int a[n + 1];
  for (i = 1; i <= n; i++) {
    scanf("%1d", &a[i]);
    if (i % 2 != 0) {
      if (a[i] % 2 == 0) even++;
    } else {
      if (a[i] % 2 != 0) odd++;
    }
  }
  long long int n2 = (n + 1) / 2 - even, n3 = n / 2 - odd;
  long long int digits = n;
  long long int flag = 0;
  while (digits != 1) {
    if (flag == 0) {
      if (even > 0) {
        even--;
        flag = 1;
      } else {
        n2--;
        flag = 1;
      }
    } else {
      if (odd > 0) {
        odd--;
        flag = 0;
      } else {
        n3--;
        flag = 0;
      }
    }
    digits--;
  }
  if (even >= 1 || n3 >= 1)
    cout << "2\n";
  else
    cout << "1\n";
}
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) solve();
}
