#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=200005,INF=1<<30;

ll C[10005][105];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    string S;cin>>S;
    vector<ll> A(N+1),B(N+1);
    for(int i=0;i<N+1;i++) cin>>A[i];
    
    int left=1,right=10001;
    while(right-left>1){
        int mid=(left+right)/2;
        for(int t=0;t<mid;t++){
            for(int i=0;i<N+1;i++){
                C[t][i]=A[i]/mid;
                if(t<A[i]%mid) C[t][i]++;
            }
        }
        
        bool ok=true;
        
        for(int t=0;t<mid;t++){
            for(int i=0;i<N;i++){
                if(S[i]=='<'){
                    if(C[t][i]>=C[t][i+1]) ok=false;
                }else{
                    if(C[t][i]<=C[t][i+1]) ok=false;
                }
            }
        }
        
        if(ok) left=mid;
        else right=mid;
    }
    
    int mid=left;
    
    cout<<mid<<endl;
    
    for(int t=0;t<mid;t++){
        for(int i=0;i<N+1;i++){
            C[t][i]=A[i]/mid;
            if(t<A[i]%mid) C[t][i]++;
            cout<<C[t][i]<<" ";
        }
        cout<<"\n";
    }
    
    return 0;
    
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    string S;
    cin >> N >> S;
    vector<int> A(N + 1), d(N);
    for(int i = 0; i <= N; ++i){
        cin >> A[i];
        if(i)   d[i - 1] = abs(A[i] - A[i - 1]);
    }
    int k = *min_element(begin(d), end(d));
    cout << k << '\n';
    for(int j = 0; j < k; ++j){
        for(int i = 0; i <= N; ++i){
            cout << (A[i] + j) / k << (i == N ? '\n' : ' ');
        }
    }

    return 0;
}