#include <bits/stdc++.h>
using namespace std;
void solve();
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  bool oddodd = 0, eveneven = 0;
  for (long long i = 1; i <= n; i++) {
    if (i & 1 and (s[i - 1] - '0') & 1) oddodd = 1;
    if (!(i & 1) and !((s[i - 1] - '0') & 1)) eveneven = 1;
  }
  if (n & 1) {
    if (oddodd)
      cout << 1;
    else
      cout << 2;
  } else {
    if (eveneven)
      cout << 2;
    else
      cout << 1;
  }
  cout << "\n";
  return;
}
