#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int p;
  cin >> p;
  for (long long int z = 0; z < p; z++) {
    long long int n;
    cin >> n;
    while (1) {
      break;
    }
    string a;
    cin >> a;
    long long int re = 0, ro = 0, be = 0, bo = 0;
    for (long long int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        if (a[i] % 2 == 0) {
          re++;
        } else
          ro++;
      } else {
        if (a[i] % 2 == 0) {
          be++;
        } else
          bo++;
      }
    }
    while (1) {
      break;
    }
    if (n % 2 == 0) {
      if (be > 0)
        cout << "2\n";
      else
        cout << "1\n";
      while (1) {
        break;
      }
    } else {
      while (1) {
        break;
      }
      if (ro > 0)
        cout << "1\n";
      else
        cout << "2\n";
      while (1) {
        break;
      }
    }
  }
}
