#include <bits/stdc++.h>
#define endl '\n'

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n;
int a[MAXN];
string s;

void read() {
	cin >> n;
	cin >> s;
	for(int i = 0; i <= n; i++) {
		cin >> a[i];
	}
}

int val[MAXN];
int rem[MAXN];

bool check(int k) {
	for(int i = 0; i <= n; i++) {
		val[i] = a[i] / k;
		rem[i] = a[i] % k;
		if(i == 0) continue;

		if(s[i - 1] == '<') {
			if(val[i - 1] >= val[i]) {
				return false;
			}

			if(val[i - 1] + 1 == val[i] && rem[i - 1] > rem[i]) {
				return false;
			}
		} else {
			if(val[i - 1] <= val[i]) {
				return false;
			}
			
			if(val[i - 1] - 1 == val[i] && rem[i - 1] < rem[i]) {
				return false;
			}
		}
	}

	return true;
}

void solve() {
	int low = 2, high = (int)1e4 + 1, mid, ret = 1;
	while(low <= high) {
		mid = (low + high) >> 1;
		if(check(mid)) {
			ret = mid;
			low = mid + 1;
		} else {
			high = mid - 1;
		}
	}

	check(ret);
	cout << ret << endl;
	for(int j = 0; j < ret; j++) {
		for(int i = 0; i <= n; i++) {
			int v = a[i] / ret;
			if(j < (a[i] % ret)) v++;
			cout << v << " ";
		}

		cout << endl;
	}

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	read();
	solve();
	return 0;
}


#include<iostream>
#include<cstdio>
#define N 110
using namespace std;
int abs(int x)
{
	return x<0?-x:x;
}
char s[N];
int a[N],b[N],c[N];
int main()
{
	int n,k=999999999;
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%d",&a[1]);
	for(int i=2;i<=n+1;++i)
	{
		scanf("%d",a+i);
		k=min(abs(a[i]-a[i-1]),k);
//		printf("%d\n",k);
	}
	printf("%d\n",k);
	for(int i=1;i<=k;++i)
	{
		for(int j=1;j<=n+1;++j)
		{
			printf("%d ",a[j]/k+ (i<=(a[j]%k)?1:0));
		}
		printf("\n");
	}
	return 0;
}