#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, s = 0, q = 0, w = 0, i = 0;
    string b;
    cin >> n;
    cin >> b;
    for (int j = 0; j < n; j++) {
      if (j % 2 == 0) {
        if ((b[j] - '0') & 1) q++;
      } else if (j % 2 != 0) {
        if (!((b[j] - '0') & 1)) w++;
      }
    }
    if (n % 2 != 0) {
      if (q > 0)
        cout << "1" << endl;
      else
        cout << "2" << endl;
    } else {
      if (w > 0)
        cout << "2" << endl;
      else
        cout << "1" << endl;
    }
  }
}
