#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    n = s.length();
    vector<int> a, b;
    for (int i = 0; i < n; ++i) {
      if (i % 2 == 0) {
        a.push_back((s[i] - '0'));
      } else {
        b.push_back((s[i] - '0'));
      }
    }
    int l = 0;
    int r = a.size() - 1;
    while (l <= r) {
      if ((a[l] & 1) && !(a[r] & 1)) {
        swap(a[l], a[r]);
        l++;
        r--;
      } else if ((a[l] & 1) && (a[r] & 1)) {
        l++;
        r--;
      } else if (!(a[l] & 1) && (a[r] & 1)) {
        l++;
        r--;
      } else if (!(a[l] & 1) && !(a[r] & 1)) {
        l++;
      }
    }
    l = 0;
    r = b.size() - 1;
    while (l <= r) {
      if ((b[l] & 1) && !(b[r] & 1)) {
        l++;
        r--;
      } else if ((b[l] & 1) && (b[r] & 1)) {
        l++;
      } else if (!(b[l] & 1) && (b[r] & 1)) {
        swap(b[l], b[r]);
        l++;
        r--;
      } else if (!(b[l] & 1) && !(b[r] & 1)) {
        l++;
        r--;
      }
    }
    if (a.size() > b.size()) {
      cout << ((a.back() & 1) ? "1" : "2") << endl;
    } else {
      cout << ((b.back() & 1) ? "1" : "2") << endl;
    }
  }
  return 0;
}
static const auto speedup = []() {
  ios_base ::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return 0;
}();
