#include <bits/stdc++.h>
#define N 400005
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int T;
int n;
int a[N];
int main()
{

    n = read();
    string s;
    cin >>s;
    for(int i=1;i<= n + 1;i++) {
        a[i] = read();
    }
    int k = 1145141;
    for(int i=1;i<=n;i++) {
        k = min(k, abs(a[i + 1] - a[i]));
    }
    cout << k << endl;
    for (int i = 0; i < k; i += 1) {
        for (int j = 1; j <= n + 1; j += 1) {
            cout << (a[j] / k) + (i < a[j] % k) << ' ';
        }
        cout << endl;
    }
}
// 1 2 3 4 5 6 7 8
//

//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
//#pragma GCC optimize("Ofast")

const int maxn = 1e4 + 5;

int n, a[maxn], ans = maxn, b[maxn][105];
string s;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> s;
	for(int i = 0; i <= n; i++)
	{
		cin >> a[i];
		if(i&& (a[i - 1] < a[i]) == (s[i - 1] == '>'))
		{
			ans = 0;
		}
		
		if(i)
			ans = min(ans, abs(a[i] - a[i - 1]));
	}

	cout << ans << '\n';
	if(ans == 0)
		return 0;
	
	for(int i = 0; i <= n; i++)
	{
		for(int j = 0; j < a[i] % ans; j++)
			b[j][i] = (ans + a[i] - 1) / ans;
		for(int j = a[i] % ans; j < ans; j++)
			b[j][i] = a[i] / ans;
		
	}


	for(int i = 0; i < ans; i++)
	{
		for(int j = 0; j <= n; j++)
			cout << b[i][j] << " ";
		cout << '\n';
	}
			

}
