	//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;
	}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T> ostream &operator<<(ostream &os, multiset<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) { dump_func(__VA_ARGS__) }
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> A(N+1);
    rep(i,N+1)cin >> A[i];
    // x個に分けることができるか
    auto check = [&](int x, bool out = false) -> bool{
        vector<vector<int>> vv(x, vector<int>(N+1, 0));
        rep(i,x)rep(j,N+1){
            vv[i][j] = A[j]/x;
        }
        rep(j,N+1){
            int rem = A[j]%x;
            rep(i,rem)vv[i][j] += 1;
        }
        if(out){
            rep(i,x){
                rep(j,N+1){
                    cout << vv[i][j] << " ";
                }
                cout << endl;
            }
        }
        //
        dump(x);
        rep(i,x)rep(j,N+1)if(vv[i][j] < 0)return false;
        rep(i,x){
            rep(j,N){
                if(S[j] == '<'){
                    if(vv[i][j] >= vv[i][j+1])return false;
                }
                else{
                    if(vv[i][j] <= vv[i][j+1])return false;
                }
            }
        }
        return true;
    };
    int ok = 1;
    int ng = 1e5;
    while(ng - ok > 1){
        int mid = (ok + ng) / 2;
        dump(mid);
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    check(ok, true);
}
