import java.io.BufferedReader;
import java.io.InputStreamReader;

public class GoodString {
    public static void main (String [] args) throws Exception{
        BufferedReader bR = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(bR.readLine());
        for (int i = 0; i < t; i++) {
            int n = Integer.parseInt(bR.readLine());
            StringBuilder s = new StringBuilder(bR.readLine());
            for (int j = 1; j < n; j++) {
                if (s.charAt(j)==s.charAt(j-1)) {
                    s.deleteCharAt(j);
                    n--;
                    j--;
                }
            }
            if (s.charAt(0)=='<' && s.charAt(n-1)=='>') {
                System.out.println(1);
            }
            else {
                System.out.println(0);
            }
        }
    }
}