#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, i, counter = 0, even_at_odd = 0, odd_at_odd = 0, even = 0, odd = 0,
              even_at_even = 0, odd_at_even = 0;
    string s;
    scanf("%d", &n);
    cin >> s;
    for (i = 0; i < n; ++i) {
      if ((s[i] - '0') % 2 == 0) {
        even++;
        if (i % 2 == 0) {
          even_at_odd++;
        } else {
          even_at_even++;
        }
      } else {
        odd++;
        if (i % 2 == 0) {
          odd_at_odd++;
        } else {
          odd_at_even++;
        }
      }
    }
    if (n == 1) {
      if (even) {
        printf("2\n");
        continue;
      } else {
        printf("1\n");
        continue;
      }
    }
    if (n % 2 == 0) {
      even -= even_at_odd;
      odd -= odd_at_odd;
      odd -= odd_at_even;
      even -= max(even_at_even - 1, 0);
      if (even) {
        printf("2\n");
      } else {
        printf("1\n");
      }
    } else {
      odd -= odd_at_even;
      even -= even_at_even;
      even -= even_at_odd;
      odd -= max(odd_at_odd - 1, 0);
      if (odd) {
        printf("1\n");
      } else {
        printf("2\n");
      }
    }
  }
  return 0;
}
