#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void debug() { cerr << "]\n"; }
template <class H, class... T>
void debug(H h, T... t) {
  cerr << h;
  if (sizeof...(t)) {
    cerr << ", ";
  }
  debug(t...);
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int o, e;
  o = e = 0;
  int f1, f2;
  f1 = f2 = 0;
  for (int i = 0; i < n; i++) {
    if (i & 1) {
      if ((int)(s[i] - '0') & 1) {
      } else
        f2 = 1;
    } else {
      if ((int)(s[i] - '0') & 1) {
        f1 = 1;
      }
    }
  }
  if (n == 1) {
    cout << (((s[0] - '0') & 1) ? "1" : "2") << "\n";
    return;
  }
  if (n & 1) {
    cout << (f1 ? "1" : "2") << "\n";
  } else {
    cout << (f2 ? "2" : "1") << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int _;
  cin >> _;
  for (int i = 1; i <= _; i++) {
    solve();
  }
  return 0;
}
