#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> t;
  string s;
  for (int tt = 0; tt < t; tt++) {
    cin >> n >> s;
    int right_oriented_idx = INT_MAX, left_oriented_idx = INT_MIN;
    for (int i = 0; i < n; i++) {
      if (s[i] == '>' && i < right_oriented_idx) {
        right_oriented_idx = i;
      }
      if (s[i] == '<' && i > left_oriented_idx) {
        left_oriented_idx = i;
      }
    }
    if (right_oriented_idx == INT_MAX || left_oriented_idx == INT_MIN ||
        right_oriented_idx == 0 || left_oriented_idx == n - 1) {
      cout << 0 << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
