#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9 + 7, MAX = 1e6 + 5;
const long long INF = 1e18 + 5;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> E, O;
    for (int i = 0; i < n; i++) {
      if (i % 2)
        E.push_back(s[i] - '0');
      else
        O.push_back(s[i] - '0');
    }
    if (n % 2) {
      bool raze = false;
      for (auto num : O)
        if (num % 2) raze = true;
      if (raze)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else {
      bool breach = false;
      for (auto num : E)
        if (num % 2 == 0) breach = true;
      if (!breach)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
}
