
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.function.Supplier;
import java.util.*;

public class GoodString {
    static Supplier<InputStream> inputSupplier = () -> System.in;
    static Supplier<PrintWriter> outSupplier = () -> new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(inputSupplier.get());
        PrintWriter out = outSupplier.get();
        int t = sc.nextInt();

        for (int i = 0; i < t; i++) {
            int n = sc.nextInt();
            String s = sc.next();
            ArrayDeque<Character> stack = new ArrayDeque<>();
            for (int j = 0; j < n; j++) {
                char curr = s.charAt(j);
                if (!stack.isEmpty()) {
                    if (stack.peek() == '<') {
//                        if (curr == '<') {
//                            // consume
//                            stack.pop();
//                        } else {
                        stack.push(curr);
//                        }
                    } else { // peek== >
                        if (curr == '<')
                            stack.pop();
                        else
                            stack.push(curr);
                    }
                } else {
                    stack.push(curr);
                }
            }
            int result = 0;

            if (stack.size() > 1 &&
                    (stack.peekFirst() == '>' && stack.peekLast() == '<')) {
                result = 1;
                int c = 0;
                while (!stack.isEmpty() && (stack.peekFirst() == '>')) {
                    stack.pollFirst();
                    c++;
                }
                if (c % 2 == 0) result = 0;
                else {
                    c = 0;
                    while (!stack.isEmpty() && (stack.peekLast() == '<')) {
                        stack.pollLast();
                        c++;
                    }
                    if (c % 2 == 0) result = 0;
                }
            }
            out.println(result);

        }
        sc.close();
        out.close();
    }
}
