#include <bits/stdc++.h>
using namespace std;
long long int powe(long long int x, long long int n) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return powe((x % 1000000007 * x % 1000000007) % 1000000007, n / 2) %
           1000000007;
  return (x % 1000000007 *
          powe((x % 1000000007 * x % 1000000007) % 1000000007, (n - 1) / 2)) %
         1000000007;
}
long long int gcd(long long int A, long long int B) {
  if (B == 0) return A;
  return gcd(B, A % B);
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    if (n == 1) {
      if ((s[0] - '0') % 2 == 0)
        cout << "2" << endl;
      else
        cout << "1" << endl;
      continue;
    }
    long long int p = 0;
    long long int q = 0;
    long long int l = 0, m = 0;
    for (long long int i = 0; i < n; i++) {
      if ((s[i] - '0') % 2 == 0)
        l = 1;
      else
        m = 1;
    }
    if (l == 0) {
      cout << "1" << endl;
      continue;
    } else if (m == 0) {
      cout << "2" << endl;
      continue;
    }
    for (long long int i = 0; i < n; i++) {
      if ((s[i] - '0') % 2 == 0 && i % 2 == 1) q = 1;
      if ((s[i] - '0') % 2 == 1 && i % 2 == 0) p = 1;
    }
    if (n % 2 == 1 && p == 1) {
      cout << "1" << endl;
    } else if (n % 2 == 1) {
      cout << "2" << endl;
    } else if (n % 2 == 0 && q == 1) {
      cout << "2" << endl;
    } else if (n % 2 == 0) {
      cout << "1" << endl;
    }
  }
}
