#include <bits/stdc++.h>
using namespace std;
priority_queue<long long int, vector<long long int>, greater<long long int> > q;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int ara[n];
    for (long long int i = 0; i < n; i++) scanf("%1lld", &ara[i]);
    long long int e = 0, o = 0;
    if (n == 1) {
      if (ara[0] % 2 == 0)
        cout << "2" << endl;
      else
        cout << "1" << endl;
    } else if (n % 2 == 0) {
      for (long long int i = 1; i < n; i += 2) {
        if (ara[i] % 2 == 0)
          e++;
        else
          o++;
      }
      if (e == 0)
        cout << "1" << endl;
      else
        cout << "2" << endl;
    } else {
      for (long long int i = 0; i < n; i += 2) {
        if (ara[i] % 2 == 0)
          e++;
        else
          o++;
      }
      if (o == 0)
        cout << "2" << endl;
      else
        cout << "1" << endl;
    }
  }
}
