#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool odd = false, even = false;
    for (int i = 1; i <= n; i++) {
      if (i % 2 != 0) {
        odd |= ((s[i - 1] - '0') % 2 != 0);
      } else {
        even |= ((s[i - 1] - '0') % 2 == 0);
      }
    }
    if (n % 2 != 0) {
      if (odd)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    } else {
      if (even)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
  }
}
