#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int d;
    string n;
    cin >> d >> n;
    bool odd = false, even = false;
    for (int i = 1; i <= d; i++) {
      if (i % 2 == 0) {
        if (n[i - 1] % 2 == 0) even = true;
      } else {
        if (n[i - 1] % 2 == 1) odd = true;
      }
    }
    if (d % 2 == 0)
      cout << (even ? 2 : 1) << '\n';
    else
      cout << (odd ? 1 : 2) << '\n';
  }
  return 0;
}
