#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int oo = 0, oe = 0, eo = 0, ee = 0;
  int i = 0;
  while (i < n) {
    char c = s[i];
    int a = (int)c - 48;
    if (i % 2 == 0) {
      if (a % 2 == 0)
        oe++;
      else
        oo++;
    } else {
      if (a % 2 == 0)
        ee++;
      else
        eo++;
    }
    i++;
  }
  if (n % 2 == 0) {
    if (ee >= 1)
      cout << 2;
    else
      cout << 1;
  } else {
    if (oo >= 1)
      cout << 1;
    else
      cout << 2;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    solve();
    cout << "\n";
  }
  return 0;
}
