#include <bits/stdc++.h>
using namespace std;
int dr[] = {1, 0, -1, 0};
int dc[] = {0, 1, 0, -1};
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int R = 0, B = 0;
  if ((n - 1) % 2 == 0) {
    R = (n - 1) / 2;
    B = R;
  } else {
    R = (n - 1) / 2;
    B = R;
    R++;
  }
  for (int i = 0; i < n; i++) {
    int num = s[i] - '0';
    if ((i + 1) % 2 != 0 && num % 2 == 0 && R > 0) {
      s[i] = 'A';
      R--;
    } else if ((i + 1) % 2 == 0 && num % 2 != 0 & B > 0) {
      s[i] = 'A';
      B--;
    }
  }
  for (int i = 0; i < n; i++) {
    if ((i + 1) % 2 != 0 && R > 0 && s[i] != 'A') {
      s[i] = 'A';
      R--;
    } else if ((i + 1) % 2 == 0 && B > 0 && s[i] != 'A') {
      s[i] = 'A';
      B--;
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] != 'A') {
      int num = s[i] - '0';
      if (num % 2 == 0)
        cout << "2" << endl;
      else
        cout << 1 << endl;
      break;
    }
  }
}
void kick_ass() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
int main() { kick_ass(); }
