#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair
#define pll pair<long long,long long>

using namespace std;

const int nax = 105;
int n;
char s[nax];
int a[nax];

vector<vector<int> > cols;

void solve(){
    cin >> n;
    string x; cin >> x;
    for(int i=1;i<=n;i++) s[i] = x[i - 1];
    for(int i=0;i<=n;i++) cin >> a[i];
    int ile = 1e9;
    for(int i=1;i<=n;i++){
        ile = min(ile, abs(a[i] - a[i - 1]));
    }
    vector<int> fi;
    for(int i=1;i<=ile;i++){
        fi.pb(a[0] / ile);
        if(i <= a[0] % ile) fi.back()++;
    }
    cols.pb(fi);
    for(int i=1;i<=n;i++){
        if(s[i] == '<'){
            // jestesmy wieksi
            vector<int> last = cols.back();
            vector<int> now;
            int rest = a[i];
            for(int j=1;j<=ile;j++){
                now.pb(last[j - 1] + 1);
                rest -= (last[j - 1] + 1);
            }
            int prefix = -1;
            if(now[0] == now[ile - 1]) prefix = ile - 1;
            else{
                for(int j=1;j<ile;j++){
                    if(now[j] < now[j - 1]){
                        prefix = j - 1;
                        break;
                    }
                }
            }
            while(rest--){
                prefix++;
                if(prefix == ile) prefix = 0;
                now[prefix]++;
            }
            cols.pb(now);
        }
        else{
            vector<int> last = cols.back();
            vector<int> now;
            int rest = a[i];
            for(int j=1;j<=ile;j++){
                now.pb(last[j - 1] - 1);
                rest -= (last[j - 1] - 1);
            }
            int prefix = -1;
            if(now[0] == now[ile - 1]) prefix = ile - 1;
            else{
                for(int j=1;j<ile;j++){
                    if(now[j] < now[j - 1]){
                        prefix = j - 1;
                        break;
                    }
                }
            }
            while(rest < 0){
                rest++;
                now[prefix]--;
                prefix--;
                if(prefix == -1) prefix = ile - 1;
            }
            cols.pb(now);
        }
    }
    cout << ile <<"\n";
    for(int j=0;j<ile;j++){
        for(int i=0;i<=n;i++){
            cout << cols[i][j] <<" " ;
        }
        cout << "\n";
    }


}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int tt = 1;
    // cin >> tt;
    while(tt--) solve();
    return 0;
}

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

int main() {
  int n;
  string s;
  vector<int> a(n + 1);
  cin >> n >> s;
  for (int i = 0; i < n + 1; ++i) {
    scanf("%d", &a[i]);
  }
  int l = 1, r = 10005;
  while (l + 1 < r) {
    int m = (l + r) / 2;
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
      int q1 = a[i - 1] / m;
      int r1 = a[i - 1] % m;
      int q2 = a[i] / m;
      int r2 = a[i] % m;
      if (s[i - 1] == '>') {
        swap(q1, q2);
        swap(r1, r2);
      }
      if (q1 == q2) {
        ok = false;
        break;
      }
      if (q1 + 1 == q2) {
        if (r1 > r2) {
          ok = false;
          break;
        }
      }
    }
    if (!ok) r = m;
    else l = m;
  }
  cout << l << endl;
  vector<int> rem(n + 1);
  for (int i = 0; i < n + 1; ++i) {
    rem[i] = a[i] % l;
  }
  for (int t = 0; t < l; ++t) {
    for (int i = 0; i < n + 1; ++i) {
      int q = a[i] / l;
      if (t < rem[i]) {
        cout << q + 1;
      } else {
        cout << q;
      }
      if (i == n) cout << endl;
      else cout << " ";
    }
  }
}