using namespace std;
#include <bits/stdc++.h>
#define N 105
#define INF 1000000000
int n;
char str[N];
int a[N],b[N],c[N];
int main(){
	scanf("%d%s",&n,str+1);
	for (int i=0;i<=n;++i)
		scanf("%d",&a[i]);
	int k=INF;
	for (int i=1;i<=n;++i)
		if (str[i]=='<')
			k=min(k,a[i]-a[i-1]);
		else
			k=min(k,a[i-1]-a[i]);
//	for (int i=0;i<=n;++i){
//		b[i]=a[i]/k;
//		c[i]=a[i]-b[i]*(k-1);
//	}
	printf("%d\n",k);
	for (int i=1;i<=k;++i,printf("\n"))
		for (int j=0;j<=n;++j)
			printf("%d ",a[j]/k+(i<=a[j]%k?1:0));
//	for (int i=1;i<=k-1;++i,printf("\n"))
//		for (int j=0;j<=n;++j)
//			printf("%d ",b[j]);
//	for (int j=0;j<=n;++j)
//		printf("%d ",c[j]);
	return 0;
}









	//IQ134高知能系Vtuberの高井茅乃です。
	//Twitter: https://twitter.com/takaichino
	//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

	#define INF INT_MAX
	#define LLINF LLONG_MAX
	#define REP(i,n) for(int i=0;i<n;i++)
	#define REP1(i,n) for(int i=1;i<=n;i++)
	#define MODA 1000000007
	#define MODB  998244353 

	template <typename T>
	std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
		for (T& x: vec) { is >> x; }
		return is;
	}



	int main() {
		ll ans = 0;
		ll tmp = 0;
		int n; cin >> n;
		string s; cin >> s;
		vector<int> a(n+1); cin >> a;
		int mi[n+1] = {};
		REP(i, n) if(s[i] == '<') mi[i+1] = max(mi[i+1], mi[i]+1);
		for(int i = n; i >= 0; i--) if(s[i] == '>') mi[i] = max(mi[i], mi[i+1]+1);
		ans = INF;
		//REP(i, n+1) if(mi[i] > 0) ans = min(ans, (ll)(a[i]/mi[i]));
		REP(i, n) ans = min(ans, (ll)abs(a[i] - a[i+1]));
		cout << ans << endl;
		REP(i, ans){ REP(j, n+1){cout << (a[j] + i)/ ans << " ";} cout << endl;}
		//REP(i, ans - 1){ REP(j, n+1){cout << mi[j] << " ";} cout << endl;}
		//REP(i, n+1){cout << a[i] - mi[i] *(ans - 1) << " ";} cout << endl;
	}