#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define swap(a,b) (a^=b^=a^=b)
#define ll long long int
#define ull unsigned long long int
#define uint unsigned int
#define format(a) memset(a,0,sizeof(a))
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define dec(x,y,z) for(int x=y;x>=z;x--)
#define mst(x) memset(x,0,sizeof(x))
#define mid ((l+r)>>1)
const int maxn=1e5+10;
inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'|ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
int n;
string s;
int a[105];
int b[maxn][105];
int sm[105],snum[105],bi[105],bnum[105];
bool check(int cur)
{
    rep(i,1,n)
    {
        int val=a[i]/cur;
        int les=a[i]-a[i]/cur*cur;
        rep(j,1,cur)
        {
            b[j][i]=val;
            if(j<=les)b[j][i]++;
        }
    }
    rep(i,1,n-1)
    {
        bool ok;
        if(s[i-1]=='<')ok=0;
        else ok=1;
        rep(j,1,cur)
        {
            if(!ok&&b[j][i]>=b[j][i+1])return 0;
            if(ok&&b[j][i]<=b[j][i+1])return 0;
        }
    }
    return 1;
}
int main()
{
    cin>>n>>s;
    n++;
    rep(i,1,n)cin>>a[i];
    int l=1,r=10000;
    while(l+1<r)
    {

        if(check(mid))l=mid;
        else r=mid;
        //cout<<l<<" "<<r<<endl;
    }
    //cout<<check(2)<<endl;
    if(check(r))l=r;
    check(l);
    cout<<l<<"\n";
    rep(i,1,l)
    {
        rep(j,1,n)cout<<b[i][j]<<" ";
        cout<<"\n";
    }

    return 0;
}



#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<int> a(n + 1);
  for(int i = 0; i <= n; i++){
    cin >> a[i];    
  }

  vector<int> d(n);
  int min_d = INF;
  for(int i = 0; i < n; i++){
    d[i] = abs(a[i] - a[i + 1]);
    min_d = min(min_d, d[i]);
  }

  int k = min_d;
  vector<vector<int>> b(k, vector<int>(n + 1));
  for(int i = 0; i <= n; i++){
    for(int j = 0; j < k; j++)b[j][i] = a[i] / k;
    for(int j = 0; j < a[i] % k; j++)b[j][i] += 1;
  }

  cout << k << endl;
  for(int i = 0; i < k; i++){
    for(int j = 0; j <= n; j++){
      cout << b[i][j] << ' ';
    }
    cout << endl;
  }
  return 0;
}
