

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		new Solver().solve().end();
	}
}

class Solver {
	PrintWriter out;
	FastReader cd;
	@SuppressWarnings("unused")
	public static final int INF = 0x3f3f3f3f;
	@SuppressWarnings("unused")
	public static final double MINI = 1e-6, ATOM = 1e-8;

	Solver() {
		out = new PrintWriter(System.out, true);
		cd = new FastReader();
	}


	Solver solve() {
		int t = cd.nextInt();
		for (int i = 0; i < t; i++) {
			int n = cd.nextInt();
			String s = cd.next();
			Deque<Character> deque = new ArrayDeque<>();
			for (int j = 0; j < n; j++) {
//				out.print(s.charAt(j));
				if (deque.isEmpty()) deque.offerLast(s.charAt(j));
				else if (deque.peekFirst() == '>') {
				} else if (s.charAt(j) == '<') {
					while (!deque.isEmpty()) deque.pollLast();
					deque.offerLast(s.charAt(j));
				}
				else deque.offerLast(s.charAt(j));
//				out.println(deque);
			}
			out.println(deque.size() >= 2 ? 1 : 0);
		}
		return this;
	}

	void end() {
		out.close();
		cd.close();
	}

	@SuppressWarnings("unused")
	class FastReader {
		private BufferedReader in;
		private StringTokenizer tokenizer;

		FastReader() {
			in = new BufferedReader(new InputStreamReader(System.in), 23333);
			tokenizer = null;
		}

		String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] nextInts(int len) {
			int[] a = new int[len];
			for (int i = 0; i < a.length; i++) {
				a[i] = cd.nextInt();
			}
			return a;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				in.close();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}

