#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

vector<vector<int> > g;

void chmin(int &a, int b){
    a = min(a,b);
}

ll N, K;
ll dp[3005][3005];  // i:unit, j:cnt, k:2^k

ll rec(ll i, ll j){
    if(i==0 && j==0) return 1;
    if(i==0 || j==0) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    ll res = 0;
    if(i>=1 && j>=1) res += rec(i-1,j-1);
    if(i*2 <= j) res += rec(i*2, j);
    res %= MOD;
    return dp[i][j] = res;
}

int main(){
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            dp[i][j] = -1;
        }
    }
    cin >> N >> K;
    cout << rec(K, N) << endl;
    
    return 0;
}
//_base::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
#include <valarray>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <unordered_set>
#include <random>
#include <unordered_map>
#define mxN 1000000007
#define mat vector<vector<int>>
#define ll long long
#define pb push_back
#define all(a) a.begin(), a.end()
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h, w, mod = 998244353;
    cin >> h >> w;
    vector<string> v;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        v.pb(s);
    }
    ll ans = 1;
    for (int i = 0; i < w; ++i) {
        bool ald = true;
        int y = 0, x = i;
        set <int> s;
        while (x > -1 && y < h) {
            if (v[y][x] != '.') {
                ald = false;
                s.insert(v[y][x]);
            }
            --x;
            ++y;
        }
        if (s.size() > 1) {
            cout << 0 << endl;
            return 0;
        }
        if (ald) {
            ans *= 2;
        }
        ans %= mod;
    }
    for (int i = 1; i < h; ++i) {
        bool ald = true;
        int y = i, x = w - 1;
        set <int> s;
        while (x > -1 && y < h) {
            if (v[y][x] != '.') {
                ald = false;
                s.insert(v[y][x]);
            }
            --x;
            ++y;
        }
        if (s.size() > 1) {
            cout << 0 << endl;
            return 0;
        }
        if (ald) {
            ans *= 2;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

