#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  bool ee(false), oo(false);
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) {
      if ((s[i - 1] - '0') % 2 == 1) oo = true;
    } else {
      if ((s[i - 1] - '0') % 2 == 0) ee = true;
    }
  }
  if (n % 2 == 0) {
    if (ee)
      cout << "2\n";
    else
      cout << "1\n";
  } else {
    if (oo)
      cout << "1\n";
    else
      cout << "2\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
