#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7f7f7f7f;
const long long INF = 2e18;
const int N = 1e3 + 10;
const unsigned long long base = 1313131;
const long long base1 = 131;
const long long mod = 998244353;
const double PI = acos(-1);
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline string readstring() {
  string str;
  char s = getchar();
  while (s == ' ' || s == '\n' || s == '\r') {
    s = getchar();
  }
  while (s != ' ' && s != '\n' && s != '\r') {
    str += s;
    s = getchar();
  }
  return str;
}
int random(int n) { return (int)(rand() * rand()) % n; }
void writestring(string s) {
  int n = s.size();
  for (int i = 0; i < n; i++) {
    printf("%c", s[i]);
  }
}
char s[N];
void solve() {
  int n = read();
  scanf("%s", s + 1);
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 1; i <= n; i++) {
    int x = s[i] - '0';
    if (i % 2 && x % 2 == 0) a++;
    if (i % 2 && x % 2) b++;
    if (i % 2 == 0 && x % 2 == 0) c++;
    if (i % 2 == 0 && x % 2) d++;
  }
  for (int i = 1; i < n; i++) {
    if (i % 2) {
      if (a)
        a--;
      else
        b--;
    } else {
      if (d)
        d--;
      else
        c--;
    }
  }
  if (b || d)
    puts("1");
  else
    puts("2");
}
int main() {
  int t = read();
  while (t--) {
    solve();
  }
  return 0;
}
