/*
            ********************
			**    MEET SHAH   **
			**     DA-IICT    **
			**  decoder_0712  **
			********************
*/
#include <bits/stdc++.h>
using namespace std;

//#include <time.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define setpre(x,d) fixed<<setprecision(d)<<x
//#define fill(a,x) memset(a,x,sizeof(a));
#define inarr(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define outarr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define maxa(a,n) *max_element(a,a+n)
#define mina(a,n) *min_element(a,a+n)
#define fr(i,s,e) for(ll i=s;i<e;i++)
#define rf(i,s,e) for(ll i=s-1;i>=e;i--)
#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define sz size()
#define len length()
#define all(v) v.begin(),v.end()
#define PI 3.141592653589793
#define MOD 1000000007
#define NN (const int)5e5+10
#define ub upper_bound

typedef long long int ll;
typedef long double lld;
typedef pair<long long,long long> pll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;

bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) { return (a.second < b.second); }
// void fileio()	{	freopen("input.txt","r",stdin);	freopen("output.txt","w",stdout);	}
//	vll fact(NN),invfact(NN);
//	void EE(ll a,ll b,ll &x,ll &y) {	if(b==0) {	x=1,y=0; return ;	}		EE(b,a%b,x,y);	ll temp=x; x=y; y=temp-(a/b)*y;	}
//	ll inverse(ll a,ll mod) 	{	ll x,y;	EE(a,mod,x,y);	return (x+mod)%mod;	}
//	void build() { fact[0]=1; fr(i,1,NN) fact[i]=(fact[i-1]*i)%MOD;	invfact[NN-1]=inverse(fact[NN-1],MOD); rf(i,NN-1,0) invfact[i]=(invfact[i+1]*(i+1))%MOD; }
//	ll ncr(ll n,ll r)       	{	if(n<0 || r<0 || r>n) return 0;	return (fact[n]*((invfact[n-r]*invfact[r])%MOD))%MOD;	}
//	ll choose(ll n,ll k) 	  	{	if(k==0)  return 1; return (n* choose(n-1,k-1))/k;	}
ll logy(ll x,ll y)	{	return ceil((lld)(log(x)/log(y)));	}
ll powe(ll a,ll b)	{	ll re=1;	while(b){	if(b&1) re=(re*a)%MOD;	a=(a*a)%MOD;	b=b>>1;}	return re;	}
/*
ll i,j,x,y,k,z,cnt;
vector<vector<ll> > a(100005);
vector<ll> vis(100005,0),visited(100005,0);
void dfs(int u)
{
    visited[u]=1;
    
    vector<ll>::iterator it;
    
    for(it=a[u].begin();it!=a[u].end();it++)
    {
        if(visited[*it]==0)
        {
            dfs(*it);
        }
    }
}
*/

bool flag=0,flag1=0,flag2=0;

int main()
{
	IOS
	ll a,b,c,d,ans;
	cin>>a>>b>>c>>d;
	ll t1=a-c;
	ll t2=a-d;
	ll t3=b-c;
	ll t4=b-d;
	ll mx1=max(t1,t2);
	ll mx2=max(t3,t4);
	cout<<max(mx1,mx2)<<endl;
	
	
	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];
	FOR(i,N) {
		if(S[i]=='<') L[i+1]=L[i]+1;
		else L[i+1]=0;
	}
	for(i=N-1;i>=0;i--) {
		if(S[i]=='>') R[i]=R[i+1]+1;
		else R[i]=0;
	}
	FOR(i,N+1) {
		B[i]=max(L[i],R[i]);
		P[i]={-B[i],i};
	}
	sort(P,P+N+1);
	
	
	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;
}
