#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long maxn = 1e5 + 1;
const long long inf = LLONG_MAX;
const long long minf = LLONG_MIN;
bool solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  if (n & 1) {
    for (long long i = 0; i < n; i += 2) {
      string st = "";
      st += s[i];
      if (stoi(st) & 1) return true;
    }
    return false;
  } else {
    for (long long i = 1; i < n; i += 2) {
      string st = "";
      st += s[i];
      if (!(stoi(st) & 1)) return false;
    }
    return true;
  }
  return true;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    if (solve()) {
      cout << 1 << "\n";
    } else {
      cout << 2 << "\n";
    }
  }
  return 0;
}
