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