#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2 == 0) {
    bool f = 0;
    for (long long i = 1; i < n; i += 2) f |= ((s[i] - '0') % 2 == 0);
    cout << (f ? 2 : 1) << "\n";
  } else {
    bool f = 0;
    for (long long i = 0; i < n; i += 2) f |= ((s[i] - '0') % 2);
    cout << (f ? 1 : 2) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
}
