#include<iostream>
#include<vector>
using namespace std;
const int N = 2e5;
int n;
int a[N],c[N];
int main(){
	cin>>n;
	string b;
    cin>>b;
    int minn = 1e9;
  	for(int i=1;i<=n+1;i++)	cin>>a[i], minn=min(minn,a[i]);
  	b = " " + b;
  	
  	int k = -1;
  	for(int i=10000;i>=1;i--){
  	    int now = a[1] / i;
  	    int nxt;
  	    bool fl = true;
  	    for(int j=1;j <= n; j++){
  	        nxt = a[j + 1] / i;
  	        if((b[j]=='<' and now >= nxt)||(b[j]=='>' and now <= nxt)){
  	            fl = false;
  	            break;
  	        }
  	        now = nxt;
  	    }
  	    if(fl){
  	        for(int j=1;j <= n; j++){
  	            now = a[j] / i;
  	            nxt = a[j + 1] / i;
  	            if(b[j]=='<'){
  	                if(a[j]%i>a[j+1]%i and nxt-now<=1) fl = false;
  	            }
  	            else{
  	                if(a[j]%i<a[j+1]%i and now-nxt<=1) fl = false;
  	            }
  	        }
            if(!fl) continue;
  	        k = i;
  	        break;
  	    }
  	}
  	cout<<k<<'\n';
  	for(int i=1;i<=n+1;i++)   c[i] = a[i]%k;
  	
  	for(int i=1;i<=k;i++){
  	    for(int j=1;j<=n+1;j++){
  	        if(c[j]){cout<<a[j]/k+1<<' ';    c[j]--;}
  	        else     cout<<a[j]/k<<' ';
  	    }
  	    puts("");
  	}

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,X;
vector<ll> A;
vector<ll> coff_max;
vector<ll> coff_x;

inline void input(){
    fast_io();
    cin >> N >> X;
    A = fetch_vec<ll>(N);
}

void kuriagari(vector<ll> &y){
    int n = y.size();
    for (int i = 0; i < n-1; i++)
    {
        if(y[i]==coff_max[i]){
            y[i] = 0;
            y[i+1]++;
        }
    }
}

int tlesolve(){
    coff_x.assign(N,0);
    coff_max.assign(N,0);
    // vector<ll> coff_max.assin(N,0);
    coff_max[N-1] = 100;
    for (int i = 0; i < N-1; i++)
    {
        coff_max[i] = A[i+1]/A[i];
    }
    
    for (int i = N-1; i >= 0; i--)
    {
        coff_x[i] = X/A[i];
        X %= A[i];
    }

    vector<vector<ll>> ys;
    ys.push_back(coff_x);
    for (int i = 0; i < N; i++)
    {
        vector<vector<ll>> tmp = ys;
        for(auto y:ys){
            if(y[i]!=0 && i!=N-1){
                vector<ll> ny = y;
                ny[i] = 0;
                ny[i+1]++;
                kuriagari(ny);
                tmp.push_back(ny);
            }
        }
        ys = tmp;
    }
    cout << ys.size() << endl;
    debug(coff_x);
    debug(coff_max);
    sort(ys.begin(),ys.end());
    debug(ys);
    return 0;
}   


int solve(){
    coff_x.assign(N,0);
    coff_max.assign(N,0);
    // vector<ll> coff_max.assin(N,0);
    for (int i = 0; i < N-1; i++)
    {
        coff_max[i] = A[i+1]/A[i];
    }
    ll Y = X;
    for (int i = N-1; i >= 0; i--)
    {
        coff_x[i] = X/A[i];
        Y %= A[i];
    }
    coff_max[N-1] = coff_x[N-1]+2;
    debug(coff_x);
    debug(coff_max);
    
    vector<map<ll,ll>> dp(N+1);
    dp[N][X] = 1;
    for (int i = N-1; i >= 0; i--)
    {
        for(auto [d,c]:dp[i+1]){
            // for (int x = -coff_max[i]+1; x < coff_max[i]; x++)
            // {
            //     if(abs(d-x*A[i]) < A[i]) dp[i][d-x*A[i]] += c;
            // }
            if(d > 0){
                ll x = d/A[i];
                if(x < coff_max[i]){                
                    dp[i][d-x*A[i]] += c;
                }
                if(x+1 < coff_max[i]){                
                    dp[i][d-(x+1)*A[i]] += c;
                }
            }
            else if(d < 0){
                ll x = abs(d)/A[i];
                if(abs(x) < coff_max[i]){                
                    dp[i][d+x*A[i]] += c;
                }
                if(abs(x+1) < coff_max[i]){                
                    dp[i][d+(x+1)*A[i]] += c;
                }
            }
            else{
                dp[i][d] += c;
            }
        }
    }
    debug(dp);
    cout << dp[0][0] << endl;
    return 0;
}

int main()
{
    input();
    solve();
    return 0;
}
