
import java.util.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
  
public class Graph
{ 	
static int ans=0;
	
	static int rank[];
	static int p[];
	static int max=0;
	static int a,b,c,n;
	static ArrayList<Long> arr;
    ArrayList<Pair> adj;
	int parent;
	int indeg;
	int outdeg;
	int child;
	int value;
	int vis;
	int dist;
	static Graph graph[];
	
	Graph(int val)
	{
		adj=new ArrayList<>();
		parent=-1;
		indeg=0;
		outdeg=0;
		child=-1;
		value=val;
		vis=0;
		dist=0;
		
	}
	
	static long power(long x, long y, long p) 
    { 
        // Initialize result 
        long res = 1;      
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
      
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    } 
	
	
	
	
	//unordered here
	static void add_edge(int u, Pair d)
	{
		graph[u].adj.add(d);
		d.x.adj.add(new Pair(graph[u],d.y));
		
	}
	
	static int lower_bound(int start,int end,long value) 
	{

		while(start<end)
		{
			int mid=(start+end)/2;
			if(arr.get(mid)>=value)
			end=mid;
			else start=mid+1;
		}if(arr.get(start)<=value)
			return start+1;
		else
		
		return start;
	}

	static int upper_bound(int start,int end,long value) {

		while(start<end)
		{
		int mid=(start+end)/2;
		if(arr.get(mid)<=value)
			start=mid+1;
		else end=mid;
		}
		if(arr.get(start)<=value)
			return start+1;
		else
		
		return start; 
	} 

	/*static boolean check(char [] word, int index) {
		for (char cc : word) {
		if (cc != c[index]) {
			return false;
		}
		index++;
		}
		return true;
	}*/
  static void dfs(int index)
  {
	  Graph z=graph[index];
	  z.vis=1;max++;
	  for(int i=0;i<z.adj.size();i++)
	  {
		  if(z.adj.get(i).x.vis==0&&z.adj.get(i).y==0)
		  {
			
			  dfs(z.adj.get(i).x.value);
		  }
	  }
  }
  static void initialize(int n)
  {
	  for( int i=1; i<=n; i++)
	  {		  
			rank[i]=0;
			p[i]=i;
	  }
  }//apply two heuristics to get req. time complexity
  static int findSet(int a)
  {
	  if(p[a]!=a)
	  {
		  p[a]=findSet(p[a]);
	  }
	  return p[a];
  }
  static void mergeSet(int a, int b)
  {
	  int sa=findSet(a);
	  int sb=findSet(b);
	  if(sa!=sb)
	  {
		  ans--;
		  if(rank[sa]>rank[sb])
		  {
			  p[sb]=sa;
		  }
		  else if(rank[sb]>rank[sa])
		  {
			  p[sa]=sb;
		  }
		  else
		  {
			  p[sa]=sb;
			  rank[sb]++;
		  }
	  }
  }

  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 

		
				
		
        /*Queue<Graph> q=new LinkedList<>();
        q.add(graph[index]);
        while(!q.isEmpty())
        {
            Graph z=q.peek();
            q.poll();
			z.vis=1;
           for(int i=0;i<z.adj.size();i++)
		   {
			   if(z.adj.get(i).vis==0)
			   {
				   z.adj.get(i).vis=1;
					q.add(z.adj.get(i));
			   }
                
            }
            
        }*/
		
		//min heap
		/*PriorityQueue<Long> min=new PriorityQueue<>();
		//in case you need max heap i'm here ;0
		//just a note you can create a class that can have compare method as well here use that in you want to sort according to a parameter
		PriorityQueue<Integer> max=new PriorityQueue<>(new Comparator<Integer>()
		{
			@Override
			public int compare(Integer o1, Integer o2)
			{
				return Integer.compare(o2,o1);
			}
		});*/
		int t=sc.nextInt();
		while(t-->0)
		{
			int n=sc.nextInt();
			
		String str=sc.next();
		
		int ind1=-1,ind2=-1;
		int flag=0;

for(int i=0;i<str.length();i++)
{
if(str.charAt(i)=='<')
	ind1=i;
if(str.charAt(i)=='>'&&flag==0)
{
	flag=1;
	ind2=i;
}
}
String str1="",str2="";
if(ind1!=-1)
str1=str.substring(0,ind1+1);
if(ind2!=-1)
str2=str.substring(ind2);
if(ind1!=-1&& ind2!=-1)
{
	if((str1.contains("<>")&&str2.contains("<>"))||(ind1==ind2-1&&(str.charAt(ind1)+""+str.charAt(ind2)+"").equals("<>")))
	{
		System.out.println(1);
	}
	else
		System.out.println(0);
}
else
	System.out.println(0);
	
		}	
    }
	static class Pair
	{
		Graph x;
		int y;
		Pair(Graph a, int b)
		{
			this.x =a;
			this.y =b;
		}
	}
	
	static class FastReader 
    { BufferedReader br; 
        StringTokenizer st;  public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); } 
			String next() { 
            while (st == null || !st.hasMoreElements()) 
            { try{ st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) 
                { e.printStackTrace(); 
                }} return st.nextToken(); 
        } int nextInt() { return Integer.parseInt(next()); 
        }
        long nextLong() 
        {  return Long.parseLong(next()); 
        }
        double nextDouble() 
        { return Double.parseDouble(next()); 
        } 
        String nextLine() 
        {String str = ""; 
            try
            { str = br.readLine(); 
            } 
            catch (IOException e) 
            { e.printStackTrace(); 
            } return str; }}

} 
	
	
	
	
	
	
	
		