#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // University of Warsaw
using LL = long long;
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
#define ssize(x) int((x).size())
template<class A, class B> auto& operator<<(ostream &o, pair<A, B> p) {
	return o << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &o, T x) -> decltype(x.end(), o) {
	o << '{'; int i = 0; for(auto e : x) o << (", ")+2*!i++ << e; return o << '}';
}
#ifdef DEBUG
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n + 1);
	for(int &ai : a)
		cin >> ai;

	auto good = [&](int i, int vali, int valip1) {
		if(s[i] == '<')
			return vali < valip1;
		else
			return vali > valip1;
	};

	auto get_b = [&](int k) {
		vector<vector<int>> b;
		REP(j, k) {
			vector<int> row;
			REP(i, n + 1) {
				row.emplace_back(a[i] / k + bool((a[i] % k) > j));
				if(i > 0 and not good(i - 1, row[i - 1], row[i]))
					return vector<vector<int>>();
			}
			b.emplace_back(row);
		}
		REP(j, k)
			debug(k, b[j]);
		return b;
	};

	int mx = *max_element(a.begin(), a.end());
	for(int j = mx; j >= 1; --j) {
		auto b = get_b(j);
		if(ssize(b) == 0)
			continue;
		cout << j << '\n';
#ifndef DEBUG
		for(auto &v : b) {
			for(int vi : v)
				cout << vi << ' ';
			cout << '\n';
		}
#endif
		return 0;
	}
}

#include <bits/stdc++.h>
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define rep(i,n) Rep(i,0,n)
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define _GLIBCXX_DEBUG

int main(){
  int N;cin>>N;
  string S;cin>>S;S+="<<";
  vector<int> a(N+1); rep(i,N+1) cin >> a[i];
  int k=10010;
  rep(i,N) k=min(abs(a[i]-a[i+1]),k);
  cout << k << endl;
  rep(j,k){
    vi b(N+1);
    rep(i,N+1){
      b[i]=(a[i]+j)/k;
    }
    rep(i,N+1){
      cout << b[i];
      if(i<N+1-1) cout << ' ';
      else cout << endl;
    }
  }
  return 0;
}