#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string ss;
    cin >> ss;
    int let;
    vector<int> f, s, f1, f2, s1, s2;
    for (int i = 0; i < n; ++i) {
      if (i % 2 == 0) {
        if ((ss[i] - '0') % 2 == 0)
          f1.push_back(ss[i] - '0');
        else
          f2.push_back(ss[i] - '0');
      } else {
        if ((ss[i] - '0') % 2)
          s1.push_back(ss[i] - '0');
        else
          s2.push_back(ss[i] - '0');
      }
    }
    for (auto i : f1) f.push_back(i);
    for (auto i : f2) f.push_back(i);
    for (auto i : s1) s.push_back(i);
    for (auto i : s2) s.push_back(i);
    if (f.size() == s.size())
      let = s[s.size() - 1];
    else if (f.size() > s.size())
      let = f[f.size() - 1];
    else
      let = s[s.size() - 1];
    if (let % 2)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
  }
}
