#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc = 1;
  cin >> tc;
  while (tc--) {
    int nod;
    cin >> nod;
    string num;
    cin >> num;
    bool done = false;
    if (nod % 2) {
      for (int i = 0; i < nod; i += 2) {
        if ((num[i] - '0') % 2) {
          cout << 1 << endl;
          done = true;
          break;
        }
      }
      if (!done) cout << 2 << endl;
    } else {
      for (int i = 1; i < nod; i += 2) {
        if ((num[i] - '0') % 2 == 0) {
          cout << 2 << endl;
          done = true;
          break;
        }
      }
      if (!done) cout << 1 << endl;
    }
  }
  return 0;
}
