import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
/*

横幅が l <= j <= r で、縦幅の下端が i
偶数 x[i][l][r]
奇数 y[i][l][r]

*/

const long mod = 998244353;

void main(){
	long n = read.to!long;
	long m = read.to!long;
	
	long[][] as = new long[][](n, m);
	
	foreach(i; 0 .. n){
		foreach(j; 0 .. m){
			as[i][j] = read.to!long;
		}
	}
	
	long[][][] xs = new long[][][](n, m, m);
	long[][][] ys = new long[][][](n, m, m);
	long[][] xp = new long[][](m, m);
	long[][] yp = new long[][](m, m);
	foreach(i; 0 .. n){
		foreach(l; 0 .. m){
			long sum = 0;
			foreach(r; l .. m){
				sum += r, sum %= 2;
				if(sum == 1){
					if(i > 0){
						xs[i][l][r] = yp[l][r], xs[i][l][r] %= mod;
						ys[i][l][r] = xp[l][r], ys[i][l][r] %= mod;
						xp[l][r] += xs[i][l][r], xp[l][r] %= mod;
						yp[l][r] += ys[i][l][r], yp[l][r] %= mod;
					}
					else{
						xs[i][l][r] = 0;
						ys[i][l][r] = 1;
						xp[l][r] += xs[i][l][r], xp[l][r] %= mod;
						yp[l][r] += ys[i][l][r], yp[l][r] %= mod;
					}
				}
				else{
					if(i > 0){
						xs[i][l][r] = xp[l][r], xs[i][l][r] %= mod;
						ys[i][l][r] = yp[l][r], ys[i][l][r] %= mod;
						xp[l][r] += xs[i][l][r], xp[l][r] %= mod;
						yp[l][r] += ys[i][l][r], yp[l][r] %= mod;
					}
					else{
						xs[i][l][r] = 1;
						ys[i][l][r] = 0;
						xp[l][r] += xs[i][l][r], xp[l][r] %= mod;
						yp[l][r] += ys[i][l][r], yp[l][r] %= mod;
					}
				}
			}
		}
	}
	
	long ans;
	foreach(l; 0 .. m) foreach(r; 0 .. m) ans += yp[l][r], ans %= mod;
	ans.writeln;
	
}

