#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define rng(i,m,n) for(ll (i)=(m);(i)<(n);++(i))
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#define rrng(i,m,n) for(ll (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cout<<__LINE__<<": "<<#x<<"=";view(x);
#else
#define debug(x) true
#endif
using namespace std;

string to_string(const string& e){return e;}
template<typename T,typename U> string to_string(const pair<T,U>& e){return "("+to_string(e.first)+","+to_string(e.second)+")";}
template<typename T> void view(const T& e){cout<<to_string(e)<<endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){cout<<to_string(e)<<" ";}cout<<endl;}
template<typename T> void view(const vector<vector<T>>& vv){cout<<endl;for(const auto& v : vv){view(v);}}

ll n;
string s;
VV ans;

bool ok(V &a,ll val){
    VV res(val,V());
    ll tmp=a[0];
    rep(i,val){
        res[i].push_back((tmp+val-i-1)/(val-i));
        tmp-=(tmp+val-i-1)/(val-i);
    }
    rep(i,n){
        deque<ll> div;
        tmp=a[i+1];
        rep(j,val){
            div.push_back((tmp+val-j-1)/(val-j));
            tmp-=(tmp+val-j-1)/(val-j);
        }
        if(s[i]=='<'){
            rep(j,val){
                if(res[j].back()<div.back()){
                    res[j].push_back(div.back());
                    div.pop_back();
                }else if(res[j].back()<div.front()){
                    res[j].push_back(div.front());
                    div.pop_front();
                }else{
                    return false;
                }
            }
        }else{
            rep(j,val){
                if(res[j].back()>div.front()){
                    res[j].push_back(div.front());
                    div.pop_front();
                }else if(res[j].back()>div.back()){
                    res[j].push_back(div.back());
                    div.pop_back();
                }else{
                    return false;
                }
            }
        }
    }
    ans=res;
    return true;
}

int main(){
    cin>>n;
    cin>>s;
    V a(n+1);
    rep(i,n+1)cin>>a[i];
    ll l=0;
    ll r=1e5;
    rep(i,20){
        ll mid=(l+r)/2;
        if(ok(a,mid))l=mid;
        else r=mid;
    }
    cout<<l<<endl;
    rep(i,l)view(ans[i]);
}

// In the name of god
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define Sort(x) sort(all(x))
#define debug(x) cerr << #x << " : " << x << "\n"
#define use_file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef string str;

const ll maxn = 105, inf = 1e18;
long long n, a[maxn], b[maxn];
str s;
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll k = inf;
	cin >> n >> s;
	for(ll i = 0; i <= n ; i ++){
		cin >> a[i];
		if(i)k = min(k, abs(a[i] - a[i - 1]));
	}
	cout << k << "\n";
	ll m = k;
	for(ll i = 1; i <= k; i ++){
		for(ll j = 0; j <= n; j ++){
			ll x = (a[j] + m - 1ll) / m;
			cout << x << ' ';
			a[j] -= x;
		}
		m --;
		cout << "\n";
	}
}
