//package adalabq3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
//import java.util.Map;
import java.util.StringTokenizer;

public class Main {



	
	public static void main(String[] args)throws IOException
	{
		Reader.init(System.in);
		int t = Reader.nextInt();
		
		for( int i=0; i<t; i++)
		{
		int len = Reader.nextInt();
		String s = Reader.next();
//		System.out.println((int)s.charAt(0));
		if( (int)s.charAt(0)==62 || (int)s.charAt(len-1)==60)
		{
			System.out.println(0);
			
		}
		else
			System.out.println(1);
		
		}
}
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    
    static long nextLong() throws IOException{
    	return Long.parseLong(next());
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}