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 ans;
	long[][][] xs = new long[][][](n, m, m);
	long[][][] ys = new long[][][](n, m, m);
	foreach(i; 0 .. n){
		foreach(l; 0 .. m){
			long sum = 0;
			foreach(r; l .. m){
				sum += as[i][r];
				if(sum % 2 == 1){
					if(i > 0){ // この行では奇数
						xs[i][l][r] = ys[i - 1][l][r];
						ys[i][l][r] = xs[i - 1][l][r] + 1;
						ans += ys[i][l][r], ans %= mod;
					}
					else{
						xs[i][l][r] = 0;
						ys[i][l][r] = 1;
						ans += ys[i][l][r], ans %= mod;
					}
				}
				else{ // この行では偶数
					if(i > 0){
						xs[i][l][r] = xs[i - 1][l][r] + 1;
						ys[i][l][r] = ys[i - 1][l][r];
						ans += ys[i][l][r], ans %= mod;
					}
					else{
						xs[i][l][r] = 1;
						ys[i][l][r] = 0;
						ans += ys[i][l][r], ans %= mod;
					}
				}
				debug writeln("i:", i, " l:", l, " r:", r, " sum:", sum, " xs:", xs, " ys:", ys, " ans:", ans);
			}
		}
	}
	
	ans.writeln;
	
}

