#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
typedef long long ll;
typedef std::vector<int> P;
typedef unsigned un;
ll read()
{
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return f*x;
}
using std::min;
using std::max;
template<typename T>bool umin(T& a,T t){if(a>t)return a=t,1;return 0;}
template<typename T>bool umax(T& a,T t){if(a<t)return a=t,1;return 0;}

const int MAXN = 111;
int a[MAXN],b[MAXN];
char s[MAXN];
int main()
{
	int n=read();
	scanf("%s",s+1);
	for(int i=1;i<=n+1;++i)a[i]=read();
	for(int k=10000;k;--k)
	{
		bool fail=0;
		for(int i=1;i<=k&&!fail;++i)
		{
			b[1]=(a[1]/k+(i<=a[1]%k));
			for(int j=2;j<=n+1;++j)
			{
				b[j]=(a[j]/k+(i<=a[j]%k));
				if(s[j-1]=='>')fail|=b[j-1]<=b[j];
				else fail|=b[j-1]>=b[j];
			}
		}
		if(!fail)
		{
			printf("%d\n",k);
			for(int i=1;i<=k;puts(""),++i)
				for(int j=1;j<=n+1;++j)printf("%d ",a[j]/k+(i<=a[j]%k));
			return 0;
		}
	}
	puts("0");
	return 0;
}


/*
    author:  Maksim1744
    created: 10.04.2021 15:02:52
*/

#include "bits/stdc++.h"

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> pair<T,U>& operator--           (pair<T, U> &p){--p.first; --p.second;            return  p;}
template<typename T, typename U> pair<T,U>& operator++           (pair<T, U> &p){++p.first; ++p.second;            return  p;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define SHOW_COLORS
#include "C:/C++ libs/print.cpp"
#else
#define show(...)     42
#define mclock        42
#define shows         42
#define debug if (false)
#endif

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n + 1);
    cin >> a;

    int k = 1e9;
    for (int i = 0; i < n; ++i)
        k = min(k, abs(a[i] - a[i + 1]));

    vector<vector<int>> b(k);
    for (int i = 0; i < k; ++i) {
        b[i].pb(a[0] / k);
    }
    for (int i = 0; i < a[0] % k; ++i) {
        b[i].back()++;
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] < a[i + 1]) {
            int d = a[i + 1] - a[i];
            sort(b.begin(), b.end(), [&](const auto &a, const auto &b) {
                return a.back() < b.back();
            });
            for (int i = 0; i < k; ++i) {
                b[i].pb(b[i].back() + 1);
            }
            d -= k;
            for (int i = 0; i < d; ++i) {
                b[i % k].back()++;
            }
        } else {
            int d = a[i] - a[i + 1];
            sort(b.begin(), b.end(), [&](const auto &a, const auto &b) {
                return a.back() > b.back();
            });
            for (int i = 0; i < k; ++i) {
                b[i].pb(b[i].back() - 1);
            }
            d -= k;
            for (int i = 0; i < d; ++i) {
                b[i % k].back()--;
            }
        }
    }
    cout << k << '\n';
    for (auto v : b)
        cout << v << '\n';

    return 0;
}
