#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a;
    cin >> a;
    int raze[n], brech[n];
    bool flag = true;
    int i = 0, j = 0;
    int cnt = 0;
    bool pass = true;
    if (a.length() == 1) {
      if ((a[0] - '0') % 2 == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
      pass = false;
    }
    if (pass) {
      if (a.length() % 2 == 0)
        flag = false;
      else
        flag = true;
      int kk = 0;
      int ll = a.length() - 1;
      while (ll >= 0) {
        if (flag) {
          raze[i++] = a[ll];
        } else {
          brech[j++] = a[ll];
        }
        flag = !flag;
        ll--;
      }
      bool brechh = false;
      if (i == j) {
        for (int k = 0; k < j; k++) {
          if ((brech[k] - '0') % 2 == 0) {
            brechh = true;
            break;
          }
        }
      } else {
        for (int k = 0; k < i; k++) {
          if ((raze[k] - '0') % 2 != 0) {
            brechh = false;
            break;
          }
          brechh = true;
        }
      }
      if (brechh)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
  }
  return 0;
}
