#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 2e9 + 10;
char s[mxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    cin >> s;
    vector<int> dit(n + 1);
    for (int i = 1; i <= n; i++) dit[i] = s[i - 1] - '0';
    if (n & 1) {
      int ans = 2;
      for (int i = 1; i <= n; i++)
        if (dit[i] & 1 and i & 1) ans = 1;
      cout << ans << '\n';
    } else {
      int ans = 1;
      for (int i = 1; i <= n; i++)
        if (dit[i] % 2 == 0 and i % 2 == 0) ans = 2;
      cout << ans << '\n';
    }
  }
  return 0;
}
