#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T mod_exp(T b, T p, T m) {
  T x = 1;
  while (p) {
    if (p & 1) x = (x * b) % m;
    b = (b * b) % m;
    p = p >> 1;
  }
  return x;
}
template <typename T>
T invFermat(T a, T p) {
  return mod_exp(a, p - 2, p);
}
template <typename T>
T exp(T b, T p) {
  T x = 1;
  while (p) {
    if (p & 1) x = (x * b);
    b = (b * b);
    p = p >> 1;
  }
  return x;
}
string tostring(long long int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void solve() {
  string s;
  long long int n;
  cin >> n >> s;
  bool odd_r = false, even_b = false;
  long long int b_c = 0, r_c = 0;
  for (long long int i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      if ((s[i - 1] - '0') % 2 != 0) {
        odd_r = true;
      }
      r_c++;
    } else {
      if ((s[i - 1] - '0') % 2 == 0) {
        even_b = true;
      }
      b_c++;
    }
  }
  if (r_c == b_c) {
    if (even_b)
      cout << "2"
           << "\n";
    else
      cout << "1"
           << "\n";
  } else if (r_c > b_c) {
    if (odd_r)
      cout << "1"
           << "\n";
    else
      cout << "2"
           << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
