N,M=list(map(int,input().split()));mod=998244353;base=[]

for i in range(N):

    A=input().split();s=sum(int(A[j])*2**j for j in range(M))

    for b in base:s=min(s,s^b)

    if s!=0:base.append(s)

res=N-len(base);print(((pow(2,N+M-1,mod)-pow(2,M-1+res,mod))%mod))
N,M=list(map(int,input().split()));mod=998244353;B=[]

for i in range(N):

    s=int(input().replace(" ",""),2)

    for b in B:s=min(s,s^b)

    if s!=0:B.append(s)

print(((pow(2,N+M-1,mod)*(1-pow(2,mod-1-len(B),mod)))%mod))

N, M = list(map(int, input().split()))
mod = 998244353
base = []
for i in range(N):
    A = input().split()
    s = sum(int(A[j]) * 2**j for j in range(M))
    for b in base:
        s = min(s, s ^ b)
    if s != 0:
        base.append(s)
res = N - len(base)
print(((pow(2, N + M - 1, mod) - pow(2, M - 1 + res, mod)) % mod))

N, M = list(map(int, input().split()))
mod = 998244353
B = []
for i in range(N):
    s = int(input().replace(" ", ""), 2)
    for b in B:
        s = min(s, s ^ b)
    if s != 0:
        B.append(s)
print(((pow(2, N + M - 1, mod) * (1 - pow(2, mod - 1 - len(B), mod))) % mod))

-base = [] +B = [] -    A = input().split() -    s = sum(int(A[j]) * 2**j for j in range(M)) -    for b in base: +    s = int(input().replace(" ", ""), 2) +    for b in B: -        base.append(s) -res = N - len(base) -print(((pow(2, N + M - 1, mod) - pow(2, M - 1 + res, mod)) % mod)) +        B.append(s) +print(((pow(2, N + M - 1, mod) * (1 - pow(2, mod - 1 - len(B), mod))) % mod))