#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&...tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    V<int> c(n + 1, -1);
    for (int i = 0; i <= n; i++) {
        bool f = false;
        if (i == 0 && s[0] == '<') {
            f = true;
        } else if (i == n && s[n - 1] == '>') {
            f = true;
        } else if (0 < i && i < n && s[i - 1] == '>' && s[i] == '<') {
            f = true;
        }
        if (!f) continue;
        c[i] = 0;
        for (int j = i - 1; j >= 0; j--) {
            if (s[j] == '<') break;
            chmax(c[j], c[j + 1] + 1);
        }
        for (int j = i + 1; j <= n; j++) {
            chmax(c[j], c[j - 1] + 1);
            if (s[j] == '>') break;
        }
    }
    V<int> a(n + 1);
    read(a);
    int k = 1 << 30;
    for (int i = 0; i <= n; i++) {
        if (c[i] > 0) chmin(k, a[i] / c[i]);
    }
    for (int i = 0; i < n; i++) {
        chmin(k, abs(a[i + 1] - a[i]));
    }
    cout << k << newl;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j <= n; j++) {
            if (i < a[j] % k) {
                cout << (a[j] / k) + 1;
            } else {
                cout << (a[j] / k);
            }
            if (j < n) cout << " ";
        }
        cout << newl;
    }
}

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; string s; cin >> n >> s;
  vector<int> a(n + 1); REP(i, n + 1) cin >> a[i];
  int k = INF;
  REP(i, n) chmin(k, abs(a[i + 1] - a[i]));
  cout << k << '\n';
  REP(i, k) REP(j, n + 1) cout << (a[j] + i) / k << " \n"[j == n];
  return 0;
}
