#include <cstdio>
#include <algorithm>
using namespace std;
char S[105];
int A[105];
int l[105],r[105],lcnt[105],rcnt[105];
int N,t;
bool check(int x)
{
    for(int i=0;i<=N;i++)
    {
        l[i]=A[i]/x;
        lcnt[i]=x-A[i]%x;
        r[i]=A[i]/x+1;
        rcnt[i]=A[i]%x;
    }
    for(int i=0;i<N;i++)
        if(S[i]=='<')
        {
            if(l[i]>=l[i+1])
                return false;
            if(l[i+1]==r[i]&&lcnt[i+1]>lcnt[i])
                return false;
        }
        else
        {
            if(l[i]<=l[i+1])
                return false;
            if(l[i]==r[i+1]&&lcnt[i]>lcnt[i+1])
                return false;
        }
    return true;
}
int binaryanswer(int l,int r)
{
    if(l==r)
        return l;
    if(r-l==1)
    {
        if(check(r))
            return r;
        return l;
    }
    int mid=(l+r)/2;
    if(check(mid))
        return binaryanswer(mid,r);
    else return binaryanswer(l,mid-1);
}
int main()
{
    scanf("%d",&N);
    scanf("%s",S);
    for(int i=0;i<=N;i++)
        scanf("%d",&A[i]);
    t=binaryanswer(1,10000);
    printf("%d\n",t);
    for(int i=0;i<t;i++)
    {
        for(int j=0;j<=N;j++)
            if(i<A[j]%t)
                printf("%d ",A[j]/t+1);
            else printf("%d ",A[j]/t);
        printf("\n");
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include "debug.hpp"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N; cin >> N;
  string S; cin >> S;

  vector<ll> A(N + 1, 0);
  ll K = 1e9;
  for (ll i = 0; i <= N; i++) {
    cin >> A[i];
    if (i > 0) K = min(K, abs(A[i] - A[i - 1]));
  }

  vector<vector<ll>> B(K, vector<ll>(N + 1, 0));
  for (ll i = 0; i <= N; i++) {
    ll q = A[i] / K, r = A[i] % K;
    for (ll j = 0; j < K; j++) {
      B[j][i] = q;
      if (j < r) B[j][i]++;
    }
  }

  cout << K << '\n';
  for (ll i = 0; i < K; i++) {
    cout << B[i][0];
    for (ll j = 0; j < N; j++) {
      cout << ' ' << B[i][j + 1];
    }
    cout << '\n';
  }

  return 0;
}