#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const long double eps = 1e-6;
const int mod = 1e9 + 7;
const int maxd = 3e6;
const int M = 3e6 + 10;
const int N = 2e5 + 10;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  string s;
  while (T--) {
    int n;
    cin >> n;
    cin >> s;
    int sum = 0, ans = 0;
    int flag = 0;
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    for (int i = 0; i < n - 1; ++i) {
      if (s[i] == '<')
        sum++;
      else
        ans++;
    }
    if (sum % 2 == 0 && ans % 2 == 0) flag = 1;
    sum = 0;
    ans = 0;
    for (int i = 1; i < n; ++i) {
      if (s[i] == '<')
        sum++;
      else
        ans++;
    }
    if (sum % 2 == 0 && ans % 2 == 0) flag = 1;
    if (flag)
      cout << 0 << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}
