#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    bool x = false, y = false;
    cin >> s;
    if (n == 1) {
      s[0] % 2 ? cout << "1\n" : cout << "2\n";
      continue;
    }
    for (int i = 0; i < n; i++) {
      if ((i + 1) % 2 == 1)
        x |= ((s[i] - '\0') % 2 == 1);
      else if ((i + 1) % 2 == 0)
        y |= ((s[i] - '\0') % 2 == 0);
    }
    if (n % 2 == 1) {
      x ? cout << 1 : cout << 2;
    } else {
      y ? cout << 2 : cout << 1;
    }
    cout << "\n";
  }
  return 0;
}
