#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int mod = N % 2;
    int win, count = 0;
    if (mod == 1) {
      bool t = true;
      for (int j = 0; j < N; j = j + 2) {
        if ((s[j] == '1' || s[j] == '3' || s[j] == '5' || s[j] == '7' ||
             s[j] == '9') &&
            t) {
          count = 1;
          t = false;
          continue;
        }
      }
      if (count == 1) {
        win = 1;
      } else
        win = 2;
    } else {
      bool t = true;
      for (int j = 1; j < N; j = j + 2) {
        if ((s[j] == '0' || s[j] == '2' || s[j] == '4' || s[j] == '6' ||
             s[j] == '8') &&
            t) {
          count = 1;
          t = false;
          continue;
        }
      }
      if (count == 1) {
        win = 2;
      } else
        win = 1;
    }
    cout << win << endl;
  }
}
