#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

const int maxn=1e2+10;

int arr[maxn];
string s;
int n;
bool judge(int x){
    for(int i=0;i<n;i++){
        int a=arr[i]/x,b=arr[i+1]/x;
        int aa=arr[i]%x,bb=arr[i+1]%x;
        if(s[i]=='<'){
            if(a>=b) return false;
            if(b-a==1){
                if(aa>bb) return false;
            }
        }
        else{
            if(a<=b) return false;
            if(a-b==1){
                if(aa<bb) return false;
            }
        }
    }
    return true;
}
int main()
{
    cin>>n;
    cin>>s;

    for(int i=0;i<=n;i++) scanf("%d",arr+i);

    int l=0,r=20000;
    int x=0;

    while(l<=r){
        int mid=(l+r)>>1;
        //cout<<l<<","<<r<<":"<<mid<<endl;
        if(!mid||judge(mid)){
            x=max(x,mid);
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%d\n",x);
    for(int i=0;i<x;i++){
        for(int j=0;j<=n;j++)
            printf("%d ",arr[j]/x+(i<arr[j]%x));
        putchar('\n');
    }

    return 0;
}
/*
3
<><
3 8 6 10

3
<><
8 3 6 10
*/

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define sq(n) (n)*(n)

using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using pi=pair<int,int>;
using vp=vector<pi>;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
	int n;
	string s;
	cin>>n>>s;
	n++;
	vi a(n);
	rep(i,n)cin>>a[i];
	int k=inf;
	rep(i,n-1)k=min(k,abs(a[i]-a[i+1]));
	cout<<k<<endl;
	vvi b(k,vi(n));
	rep(j,n){
		rep(i,k)b[i][j]=a[j]/k;
		int t=a[j]%k;
		rep(i,t)b[i][j]++;
	}
	rep(i,k){
		rep(j,n)cout<<b[i][j]<<sp;cout<<endl;
	}
}