#include <bits/stdc++.h>
using namespace std;
#define int long long
const int nax=105;
int a[nax];
int32_t main()
{
    int n,res=2e9;
    cin>>n;
    n++;
    string s;
    cin>>s;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<n;i++)
    res=min(res,abs(a[i]-a[i+1]));
    cout<<res<<'\n';
    for(int i=0;i<res;i++)
    {
        for(int j=1;j<=n;j++)
        cout<<(a[j]+i)/res<<' ';
        cout<<'\n';
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
string S;
int A[10101];
int L[101],R[101],B[101];
pair<int,int> P[101];
int ret[101][10101];

int hoge(int v) {
	int i,j;
	int lef[101];
	if(v>=10001) return 0;
	
	FOR(j,N+1) {
		int sum=0;
		FOR(i,v) {
			ret[j][i]=A[j]/v+(i<A[j]%v);
			sum+=ret[j][i];
		}
		assert(sum==A[j]);
	}
	
	FOR(i,N) {
		FOR(j,v) {
			if(S[i]=='<' && ret[i][j]>=ret[i+1][j]) return 0;
			if(S[i]=='>' && ret[i][j]<=ret[i+1][j]) return 0;
		}
	}
	return 1;
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	FOR(i,N+1) cin>>A[i];
	
	int re=1;
	for(i=15;i>=0;i--) if(hoge(re+(1<<i))) re+=1<<i;
	
	assert(hoge(re));
	
	
	
	cout<<re<<endl;
	FOR(i,re) {
		FOR(j,N+1) cout<<ret[j][i]<<" ";
		FOR(j,N) {
			if(S[j]=='<') assert(ret[j][i]<ret[j+1][i]);
			if(S[j]=='>') assert(ret[j][i]>ret[j+1][i]);
		}
		cout<<endl;
	}

	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
