#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e6 + 4;
const int N = 405;
int _, n;
int a[maxn], b[maxn];
char s[maxn];
int main() {
  for (scanf("%d", &_); _; _--) {
    scanf("%d", &n);
    scanf("%s", s + 1);
    int f;
    if (n & 1) {
      f = 2;
      for (int i = 1; i <= n; i += 2)
        if ((s[i] - '0') & 1) f = 1;
    } else {
      f = 1;
      for (int i = 2; i <= n; i += 2)
        if ((s[i] - '0') % 2 == 0) f = 2;
    }
    printf("%d\n", f);
  }
  return 0;
}
