#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 58, mod = 1e9 + 7;
int a[maxn], b[maxn];
vector<int> adj[maxn];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    bool f = 0;
    for (int i = 0; i < n; i++) {
      s[i] -= '0';
      if (n % 2 && i % 2 == 0 && s[i] % 2) {
        f = 1;
      } else if (n % 2 == 0 && i % 2 && s[i] % 2 == 0)
        f = 1;
    }
    if (n % 2) {
      if (f)
        cout << "1\n";
      else
        cout << "2\n";
    } else {
      if (f)
        cout << "2\n";
      else
        cout << "1\n";
    }
  }
}
