#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void print(const vector<int> &v) {
  for (int i : v) cout << i << " ";
  cout << endl;
}
void input(vector<int> &v) {
  for (int &i : v) cin >> i;
}
void swap(int *x, int *y) {
  *x ^= *y;
  *y ^= *x;
  *x ^= *y;
}
int power(int x, int y) {
  int num = 1;
  while (y--) num *= x;
  return num;
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool r = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && (s[i] - '0') % 2)
      r = 1;
    else if (i % 2 && (s[i] - '0') % 2 == 0)
      b = 1;
  }
  bool x = n % 2 == 1;
  if (x & r | !(x | b))
    cout << 1 << endl;
  else
    cout << 2 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
