#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
//#define int long long
#define pii pair<int, int>
#define pip pair<ll, pii>
#define x real
#define y imag

int solve(string s) {
    vector <pii> bl;
    int cnt = 0;
    int n = sz(s);
    for (int i = 1; i < sz(s); ++i) {
        if (s[i] == s[i - 1])
            ++cnt;
        else {
            int t = (s[i] == '<');
            bl.pb({cnt, t});
            cnt = 1;
        }
    }
    int t = (s[n - 1] == '<');
    bl.pb({cnt, t});
    for (int i = 0; i+1 < n; ++i) {
        if (bl[i].second == 1 && bl[i + 1].first == 1)
            bl[i + 1].first = 0;
    }
    for (int i = n - 1; i > 0; --i) {
        if (bl[i].second == 0 && bl[i].first && bl[i - 1].first == 1)
            bl[i - 1].first = 0;
    }
    cnt = 0;
    for (int i = 0; i < sz(bl) ; ++i) {
        cout << bl[i].first << " " << bl[i].second << endl;
        if (bl[i].first)
            ++cnt;
    }
    return cnt - 1;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        string s;
        cin >> s;
        int ans = solve(s);
        for (int i = 0; i < n; ++i)
            if (s[i] == '>')
                s[i] = '<';
            else
                s[i] = '>';
        reverse(s.begin(), s.end());
        ans = min(ans, solve(s));
        cout << ans << endl;
    }
    return 0;
}
