#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
void fun() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int oo = 0, oe = 0;
  int eo = 0, ee = 0;
  for (int i = 0; i < n; ++i) {
    int a = s[i] - '0';
    if (i % 2) {
      if (a % 2)
        ++eo;
      else
        ++ee;
    } else {
      if (a % 2)
        ++oo;
      else
        ++oe;
    }
  }
  if (n & 1) {
    if (oo > 0)
      cout << "1\n";
    else
      cout << "2\n";
  } else {
    if (ee > 0)
      cout << "2\n";
    else
      cout << "1\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  cin >> q;
  while (q--) {
    fun();
  }
  return 0;
}
