#include <bits/stdc++.h>
using namespace std;
const int maxn = 2500010;
const int maxs = 1e8 + 10;
char s[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < n; i += 2)
      if ((s[i] - '0') % 2 == 1) a++;
    for (int i = 1; i < n; i += 2)
      if ((s[i] - '0') % 2 == 0) b++;
    if (n % 2 == 1) {
      if (a > 0)
        printf("1\n");
      else
        printf("2\n");
    } else {
      if (b > 0)
        printf("2\n");
      else
        printf("1\n");
    }
  }
  return 0;
}
