#include<bits/stdc++.h> 
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define MOD 1000000007
#define INF 2000000000
#define DESPACITO 1000000000000000000
#define PI acos(-1);
#define E 998244353
#define pb push_back
#define mp make_pair
#define ll long long
#define double long double

using namespace std;

int main()
{
	IOS;
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		string s;
		cin >> s;
		int ct=0;
		char ch;
		REP(i,0,n-1)
		{
			if(i==0)
			{
				ct++;
				ch=s[i];
			}
			else if(s[i]!=s[i-1])
				ct++;
		}
		if(ch=='>')
		{
			cout << 0 << "\n";
		}
		else if(ct%2)
			cout << 0 << "\n";
		else
			cout << 1 << "\n";
	}
}