#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 88005553535;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fastio();
  ll t;
  cin >> t;
  for (ll cnt_1 = 0; cnt_1 < t; ++cnt_1) {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll cnt_odd, cnt_even;
    cnt_odd = cnt_even = 0;
    bool fl_odd_odd = false;
    bool fl_even_even = false;
    for (ll i = 0; i < n; ++i) {
      if (((i + 1) % 2 == 1) && ((s[i] - '0') % 2 == 1)) {
        fl_odd_odd = true;
      }
      if (((i + 1) % 2 == 0) && ((s[i] - '0') % 2 == 0)) {
        fl_even_even = true;
      }
    }
    if (n % 2 == 1) {
      if (fl_odd_odd)
        cout << 1;
      else
        cout << 2;
    } else {
      if (fl_even_even)
        cout << 2;
      else
        cout << 1;
    }
    cout << '\n';
  }
  return 0;
}
