#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  return ((a % 1000000007) + (b % 1000000007)) % 1000000007;
}
inline long long mul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
inline long long sub(long long a, long long b) {
  return ((a % 1000000007) - (b % 1000000007) + 1000000007) % 1000000007;
}
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long o = 0, e = 0;
  for (long long i = 0; i < n; i++) {
    if (((long long)s[i] - (long long)'0') % 2 == 1) o = 1;
    if (i + 1 < n && ((long long)s[i + 1] - (long long)'0') % 2 == 0) e = 1;
    i++;
  }
  if (n % 2 == 1) {
    if (o == 1)
      cout << "1\n";
    else
      cout << "2\n";
  } else {
    if (e == 1)
      cout << "2\n";
    else
      cout << "1\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  for (long long a = 0; a < t; a++) {
    solve();
  }
}
