#include <bits/stdc++.h>
#include <unordered_set>
#include <algorithm>
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repll(i,n) for (ll i = 0; i < (ll)(n); i++)
#define fore(x,a) for(auto&(x) : (a))
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#define ALL(a) (a).begin(), (a).end()
 
const ll INFL = 1e18;
const int INFI = 1e9;
const int MOD = 1e9 + 7;
 
int main(){
  int N;
  string S;
  cin >> N >> S;
  vll x(N+1);
  rep(i,N+1) {
    cin >> x[i];
  }
  ll M = INFL;
  rep(i,N) {
    chmin(M,abs(x[i]-x[i+1]));
  }
  vector<vector<ll>> res(M,vector<ll>(N+1));
  for (int j = 0; j <= N; j++) {
        ll r = x[j] % M;
        for (int i = 0; i < M; ++i) {
            res[i][j] = x[j] / M;
            if (i < r) res[i][j]++;
        }
  }  
  cout << M << endl;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j <= N; ++j) cout << res[i][j] << " ";
        cout << endl;
    }
}
#include<cstdio>
#include<iostream>
#include<cstring>

using namespace std;

const int maxn=1e2+10;

int arr[maxn];
string s;
int n;
bool judge(int x){
    for(int i=0;i<n;i++){
        int a=arr[i]/x,b=arr[i+1]/x;
        int aa=arr[i]%x,bb=arr[i+1]%x;
        if(s[i]=='<'){
            if(a>=b) return false;
            if(b-a==1){
                if(aa>bb) return false;
            }
        }
        else{
            if(a<=b) return false;
            if(a-b==1){
                if(aa<bb) return false;
            }
        }
    }
    return true;
}
int main()
{
    cin>>n;
    cin>>s;

    for(int i=0;i<=n;i++) scanf("%d",arr+i);

    int l=0,r=20000;
    int x=0;

    while(l<=r){
        int mid=(l+r)>>1;
        //cout<<l<<","<<r<<":"<<mid<<endl;
        if(judge(mid)){
            x=max(x,mid);
            l=mid+1;
        }
        else r=mid-1;
    }
    printf("%d\n",x);
    for(int i=0;i<x;i++){
        for(int j=0;j<=n;j++)
            printf("%d ",arr[j]/x+(i<arr[j]%x));
        putchar('\n');
    }

    return 0;
}
/*
3
<><
3 8 6 10

3
<><
8 3 6 10
*/
