#include <bits/stdc++.h>
using namespace std;
int n;
void solve() {
  int n;
  string s;
  cin >> n >> s;
  int oddr = 0, evenr = 0, oddb = 0, evenb = 0;
  int cnt = 0;
  while (cnt < n) {
    int ans = s[cnt] - '0';
    if (cnt % 2 == 0) {
      if (ans % 2 == 0)
        evenr++;
      else
        oddr++;
    } else {
      if (ans % 2 == 0)
        evenb++;
      else
        oddb++;
    }
    cnt++;
  }
  if (n % 2 == 0) {
    if (evenb)
      puts("2");
    else
      puts("1");
  } else {
    if (oddr)
      puts("1");
    else
      puts("2");
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
