#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define rev(v)  if(!v.empty())reverse(v.begin(),v.end())
#define PI 3.141592653589793238
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

ll inv_mod(ll x){
    return pow_mod(x,mod-2);
}

const ll N=(ll)3e5;
ll inv[N];
ll fac[N];

void init(){
  fac[0]=1;
  
  for(ll i=1;i<N;i++)
  fac[i]=(i*fac[i-1])%mod;
  
  for(ll i=0;i<N;i++)
  inv[i]=inv_mod(fac[i]);
}

ll ncr(ll n,ll r){
    if(n<r)
    return 0;
    
    if(n==r||r==0)
    return 1LL;
    
    ll x=fac[n];
    ll y=inv[n-r];
    ll z=inv[r];
    
    return ((x*y)%mod*z)%mod;
}
bool test_cases=0;
ll grid[10004][101];

void solve()
{
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   ll ans=-1;
   
   ++n;
   
   ll a[n];
   
   for(ll i=0;i<n;i++)
   cin>>a[i];
   
   ll l=1;
   
   ll r=(ll)1e4;
   
   while(l<=r){
       ll mid=(l+r)/2;
       
       for(ll i=0;i<n;i++){
           ll have=a[i]/mid;
           
           for(ll j=0;j<mid;j++){
               grid[j][i]=have;
           }
           
           ll rem=a[i]%mid;
           
           for(ll j=0;j<mid&&rem>0;j++,--rem)
           grid[j][i]++;
       }
       
       bool ok=true;
       
       for(ll i=0;i<mid;i++){
           for(ll j=1;j<n;j++){
               if(s[j-1]=='<'&&grid[i][j-1]>=grid[i][j]){
                   ok=false;
                   break;
               }
               if(s[j-1]=='>'&&grid[i][j-1]<=grid[i][j]){
                   ok=false;
                   break;
               }
           }
       }
       
       if(ok){
           ans=mid;
           l=mid+1;
       }
       else
       r=mid-1;
   }
   
   cout<<ans<<endl;
   
    for(ll i=0;i<n;i++){
           ll have=a[i]/ans;
           
           for(ll j=0;j<ans;j++){
               grid[j][i]=have;
           }
           
           ll rem=a[i]%ans;
           
           for(ll j=0;j<ans&&rem>0;j++,--rem)
           grid[j][i]++;
       }
   
   for(ll i=0;i<ans;i++){
           for(ll j=0;j<n;j++){
             cout<<grid[i][j]<<" ";
           }
           cout<<endl;
       }
   
}
int main()
{   
   
   // init();   //factorial calculations
   
   //Start from Here.

  ll t;
  t=1;
  
   
  while(t--)
  solve();
//Good Bye!
    return 0;
}


#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

ll dp[2001][2001];


int main()
{
	int h,w;
	cin >> h >> w;
	map<ll,ll> sumx,sumy,sumxy;
	vector<string> S(h);
	for(auto &i:S)cin >> i;
	for(int i = 0;i<h;i++){
		for(int j = 0;j<w;j++){
			if(i==0&&j==0){
				dp[i][j]=1;
				sumx[i] += 1;
				sumy[j] += 1;
				sumxy[i-j]+=1;
				continue;
			}
			if(S[i][j]=='.'){
			(dp[i][j]+=sumx[i])%=MOD;
			(dp[i][j]+=sumy[j])%=MOD;
			(dp[i][j]+=sumxy[i-j])%=MOD;
			(sumx[i]+=dp[i][j])%=MOD;
			(sumy[j]+=dp[i][j])%=MOD;
			(sumxy[i-j]+=dp[i][j])%=MOD;
			}else{
				dp[i][j] = 0;
				sumx[i]=0;
				sumy[j]=0;
				sumxy[i-j]=0;
			}
			
		}
	}
	
	cout<<dp[h-1][w-1]<<endl;
}
