#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
const long long INF = 9e18;
const long long N = 1000000007;
const double eps = 1e-9;
const auto start_time = std::chrono::high_resolution_clock::now();
void zark() {}
void solve() {
  long long n;
  cin >> n;
  vector<long long> num(n);
  string s;
  cin >> s;
  for (long long i = (0); i < (n); i++) num[i] = s[i] - '0';
  if (n & 1) {
    bool ray = false;
    for (long long i = (0); i < (n); i++)
      if (i % 2 == 0 && (num[i] & 1)) {
        ray = true;
        break;
      }
    if (ray)
      cout << "1\n";
    else
      cout << "2\n";
  } else {
    bool oth = false;
    for (long long i = (0); i < (n); i++)
      if (i % 2 == 1 && !(num[i] & 1)) oth = true;
    if (oth)
      cout << "2\n";
    else
      cout << "1\n";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  zark();
  return 0;
}
