#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<bitset>
#include<assert.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<chrono>
#include<stack>
#include<deque>
#include<random>
#define long long long
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e6,inf=1e9,mod=1e9+7;

int n;string s;

bool isOk(vector<int>v)
{
  for(int i=1;i<(int)v.size();i++)
  {
    if(v[i]==v[i-1])return false;
    if(v[i-1]<v[i] && s[i-1]=='>')return false;
    if(v[i-1]>v[i] && s[i-1]=='<')return false;
  }
  return true;
}
vector<vector<int> >ans;

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

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

  int lo=1,hi=10000,md;
  while(lo<=hi)
  {
    int md=(lo+hi)/2;

    vector<vector<int> >v(md);int f=1;
    for(int i=0;i<n+1;i++)
    {
      for(int j=0;j<md;j++)
      {
        v[j].push_back(a[i]/md);
      }
      int ex=a[i]%md;
      for(int j=0;j<ex;j++)v[j][i]++;
    }

    for(int j=0;j<md;j++)f&=isOk(v[j]);
    if(f){ans=v;lo=md+1;}
    else hi=md-1;
  }  

  cout<<(int)ans.size()<<endl;
  for(auto x:ans)
  {
    for(auto z:x)cout<<z<<" ";cout<<endl;
  }
  
  
  return 0;
}
#include<bits/stdc++.h>
using namespace std;

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 200;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,a[maxn];
char s[maxn];

int main() {
    read(n);scanf("%s",s+1);int k=1e9;
    for(int i=1;i<=n+1;i++) read(a[i]);
    for(int i=2;i<=n+1;i++) k=min(k,abs(a[i]-a[i-1]));
    write(k);
    for(int t=1;t<=k;t++) {
        for(int i=1;i<=n+1;i++) printf("%d ",(a[i]+t-1)/k);
        puts("");
    }
    return 0;
}
