#include <bits/stdc++.h>
using namespace std;
void burbuja(int* lista, const int& cont);
int main() {
  int cases;
  cin >> cases;
  for (int l = 0; l < cases; l++) {
    int n;
    cin >> n;
    string word;
    cin >> word;
    bool win = false;
    if (n % 2) {
      for (int i = 0; i < n; i += 2) {
        if (word[i] % 2) win = true;
      }
    } else {
      for (int i = 1; i < n; i += 2) {
        if (word[i] % 2 == 0) win = true;
      }
    }
    if (win) {
      if (n % 2)
        cout << 1;
      else
        cout << 2;
    } else {
      if (n % 2)
        cout << 2;
      else
        cout << 1;
    }
    cout << endl;
  }
}
void burbuja(int* lista, const int& cont) {
  bool done = false;
  while (!done) {
    done = true;
    for (int i = 1; i < cont; i++) {
      if (lista[i - 1] > lista[i]) {
        int tmp = lista[i];
        lista[i] = lista[i - 1];
        lista[i - 1] = tmp;
        done = false;
      }
    }
  }
}
