#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);

	int n;
	cin>>n;
	string s;
	cin>>s;
	int m = n+1;
	int a[m];
	int k = 1e9;
	for(int i=0;i<m;i++)cin>>a[i];
	for(int i=1;i<m;i++)chmin(k,abs(a[i]-a[i-1]));
	cout << k << endl;
	vector<vector<int>> ans(k);
	for(int i=0;i<k;i++){
		for(int j=0;j<m;j++){
			ans[i].push_back(a[j]/k);
		}
	}
	int rem[m]={};
	for(int i=0;i<m;i++)rem[i] = a[i] % k;
	for(int i=0;i<k;i++){
		for(int j=0;j<m;j++){
			if(rem[j]){
				ans[i][j]+=1;
				rem[j]--;
			}
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}
#include <bits/stdc++.h>

using namespace std;
const int MOD = 998244353;
const int N = 505;
int m, n;
char A[N][N];
struct Data
{
    int r,c;
} F[N][N];
int poww[1005];
Data combine(Data X, Data Y)
{
    if(X.r > Y.r) swap(X, Y);
    if(X.r + X.c < Y.r) return {-1,-1};
    X.c -= Y.r - X.r;
    return {Y.r,min(X.c, Y.c)};
}
int G[1005];
int main()
{
    if(fopen("A.inp","r"))
    {
        freopen("A.inp","r",stdin);
        freopen("A.out","w",stdout);
    }
    cin >> m >> n;
    poww[0] = 1;
    for(int i = 1; i <= m + n; i++) poww[i] = (poww[i-1] * 2)%MOD;
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++) cin >> A[i][j];
    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= n; j++)
        {
            int k = 0;
            if(A[i][j] == 'R') k = 1;
            if(A[i][j] == 'B') k = 2;
            if(G[i+j])
            {
                if(G[i+j] != k && k > 0)
                {
                    cout << 0;
                    return 0;
                }
            }
            else G[i+j] = k;
        }
    int cnt = 0;
    for(int i = 2; i <= m + n; i++) cnt += (G[i] == 0);
    cout << poww[cnt];
}
