#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  string s;
  bool open, close;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    open = false;
    close = false;
    for (char c : s) {
      if (c == '<') open = true;
      if (c == '>' && open) close = true;
    }
    cout << (close ? '1' : '0') << '\n';
  }
  return 0;
}
