#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int fastpower(long long int b, long long int p) {
  long long int k = p % 2 ? b : 1;
  return p == 0 ? 1 : k * (fastpower(b * b, p / 2));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2) {
      int x = 0;
      for (int i = 0; i < n; i += 2) {
        if ((s[i] - '0') % 2) {
          x = 1;
        }
      }
      cout << (x ? "1\n" : "2\n");
    } else {
      int x = 0;
      for (int i = 1; i < n; i += 2) {
        if ((s[i] - '0') % 2 == 0) {
          x = 1;
        }
      }
      cout << (x ? "2\n" : "1\n");
    }
  }
}
