#include <bits/stdc++.h>
using namespace std;
void changes() {
  long long php[4000], cdc[8000], cdm[8000];
  for (long long j = 0; j < 5; j++) {
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
    for (long long i = 0; i < 2000; i++) php[i / 10] = 1;
  }
  vector<long long> ab;
  vector<long long> ab1(1000);
  vector<long long> ab2;
  vector<long long> ab3;
  vector<long long> ab4;
  vector<long long> ab5;
  string abcd = "bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn";
  string abcd1 = "bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn cbcksknlsnv";
  string abcd2 =
      "bdcccebcaca kjbcbsnklnslknvksn  nidcldklcnlsn kjeaebbaekcmaekes";
  char abcde[1000];
  long long mfch = 0;
  long long abcdefg[1000];
  long long abcg[1000];
  long long abcfg[1000];
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n;
    string s;
    cin >> s;
    if (n == 1) {
      if ((s[0] - '0') % 2 == 0)
        cout << 2 << "\n";
      else
        cout << 1 << "\n";
      continue;
    }
    bool ans = false;
    if (n % 2 == 0) {
      ans = false;
      for (long long i = 1; i < n; i += 2) {
        if ((s[i] - '0') % 2 == 0) {
          cout << 2 << "\n";
          ans = true;
          break;
        }
      }
      if (ans == false) cout << 1 << "\n";
      continue;
    } else {
      for (long long i = 0; i < n; i += 2) {
        if ((s[i] - '0') % 2 == 1) {
          cout << 1 << "\n";
          ans = true;
          break;
        }
      }
      if (ans == false) cout << 2 << "\n";
      continue;
    }
  }
}
