#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, count = 0, right = 0, left = 0;
    cin >> n;
    char a[1000000];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == '>') {
        right++;
      } else {
        left++;
      }
    }
    if (n == 1) {
      cout << 0 << endl;
    } else {
      if (right <= left) {
        if (a[n - 1] == '>') {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
      } else {
        if (a[0] == '<') {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
      }
    }
  }
  return 0;
}
