#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define N 5114514
#define all(x) (x).begin(), (x).end()
const ll mod = 1000000007;
// const ll mod = 998244353;
const ll inf = 1000000000000000000;
void solve() {
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> a(n + 1);
    ll k = inf;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
        if (i) k = min(k, abs(a[i] - a[i - 1]));
    }
    cout << k << endl;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j <= n; j++) {
            cout << (a[j] + i) / k << ' ';
        }
        cout << endl;
    }
}

int main() {
    solve();
    return 0;
}
#include <bits/stdc++.h>
//#include <atcoder/all>
#pragma GCC target("arch=skylake-avx512")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

// index が条件を満たすかどうか
bool isOK(const vector<ll> &a, std::string S, ll index) {
  ll n = a[0] / index;
  ll m = a[0] % index;
  FOR(i, 1, a.size()) {
    ll x = a[i] / index;
    ll y = a[i] % index;
    if (S[i - 1] == '<') {
      if (n >= x) {
        return false;
      }
      if (n + 1 == x && m > y) {
        return false;
      }
    } else {
      if (n <= x) {
        return false;
      }
      if (n == x + 1 && m < y) {
        return false;
      }
    }
    swap(n, x);
    swap(m, y);
  }
  return true;
}

// 汎用的な二分探索のテンプレ
ll binary_search(const vector<ll> &a, std::string S) {
  ll ng = 100000;  //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = 1;       // 「index = a.size()-1」
                   // が条件を満たさないこともあるので、初期値は a.size()

  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;

    if (isOK(a, S, mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  return ok;
}

void solve(long long N, std::string S, std::vector<long long> A) {
  ll k = binary_search(A, S);
  cout << k << endl;
  vector<vector<ll>> v(N + 1);
  REP(i, N + 1) {
    ll n = A[i] / k;
    ll m = A[i] % k;
    REP(j, m) {
      v[i].push_back(n + 1);
    }
    REP(j, k - m) {
      v[i].push_back(n);
    }
  }
  REP(j, k) {
    REP(i, N + 1) {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  std::vector<long long> A(N - 0 + 1);
  for (int i = 0; i < N - 0 + 1; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, S, std::move(A));
  return 0;
}
