#include <bits/stdc++.h>
using namespace std;

const int N = 100 + 9;
const int N2 = 10000 + 9;

char s[N];

int a[N], b[N2][N];

bool check(int k, int n) {
    for (int i = 0; i <= n; ++i) {
        int p = a[i] / k, q = a[i] % k;
        for (int j = 1; j <= q; ++j) {
            b[j][i] = p + 1;
        }
        for (int j = q + 1; j <= k; ++j) {
            b[j][i] = p;
        }
    }
    bool f = true;
    for (int j = 1; j <= k; ++j) {
        for (int i = 1; i <= n; ++i) {
            if (s[i] == '<') {
                if (!(b[j][i - 1] < b[j][i])) f = false;
            }
            else {
                if (!(b[j][i - 1] > b[j][i])) f = false;
            }
        }
    }
    return f;
}

int main() {
    int n; scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 0; i <= n; ++i) {
        scanf("%d", a + i);
    }
    int L = 1, R = N2 - 9;
    while (L < R) {
        int M = (L + R) >> 1;
        if (check(M + 1, n)) L = M + 1;
        else R = M;
    }
    check(L, n);
    printf("%d\n", L);
    for (int j = 1; j <= L; ++j) {
        for (int i = 0; i <= n; ++i) { 
            printf("%d%c", b[j][i], i < n ? ' ' : '\n');
        }
    }
    return 0;
}
/*
*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
* 
* @author: Xingjian Bai 
* @date: 2021-04-10 13:03:21
* @description: 
*  
* 
* @notes: 
* g++ -fsanitize=address -ftrapv 
*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
#include <bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define TIME (double)clock()/CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
const int mod = 1000000007; 
const ll oo = 1e18;
const ld eps = 1e-8;
#define debug(x) cerr << "(debug mod) " << #x << " = " << x << endl

int n;
string s;
int a[110];
int b[10010][110];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> s;
    int mn = 1e9;
    for (int i = 0; i <= n; i ++) {
    	cin >> a[i];
    	if (i)
	    	mn = min (mn, abs(a[i] - a[i - 1]));
    }

    for (int i = 0; i <= n; i ++) {
    	for (int j = 1; j <= mn; j ++)
    		b[j][i] = a[i] / mn;
    	for (int j = 1; j <= a[i] - a[i] / mn * mn; j ++)
	    	b[j][i] ++;
    }

    cout << mn << endl;
    for (int i = 1; i <= mn; i ++) {
    	for (int j = 0; j <= n; j ++)
    		cout << b[i][j] << ' ';
    	cout << endl;
    }

    return 0;
}