Problem:
Score : 800 points

Problem Statement

There is a square grid with N rows and M columns.
Each square contains an integer: 0 or 1. The square at the i-th row from the top and the j-th column from the left contains a_{ij}.

Among the 2^{N+M} possible pairs of a subset A of the rows and a subset B of the columns, find the number of the pairs that satisfy the following condition, modulo 998244353:

The sum of the |A||B| numbers contained in the intersection of the rows belonging to A and the columns belonging to B, is odd.

Constraints

1 \leq N,M \leq 300

0 \leq a_{i,j} \leq 1(1\leq i\leq N,1\leq j\leq M)

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_{11} ... a_{1M}
:
a_{N1} ... a_{NM}

Output

Print the number of the pairs of a subset of the rows and a subset of the columns that satisfy the condition, modulo 998244353.

Sample Input 1

2 2
0 1
1 0

Sample Output 1

6

For example, if A consists of the first row and B consists of both columns, the sum of the numbers contained in the intersection is 0+1=1.

Sample Input 2

2 3
0 0 0
0 1 0

Sample Output 2

8

Solution in JavaScript (node.js v5.12) (judge verdict: Wrong Answer)

"use strict"
var Main=function(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var N=input.shift();
  var M=input.shift();
  var rankCounter=0;
  var A=new Matrix(N,M,input);
  while(A.low.length>0){
    let i1=0;
    for(let i=0;i<A.low.length;i++){
      if(A.low[i][0]===1)break;
      i1++;
    }
    if(i1===A.low.length){
      A.swapColumn(0,A.low[0].length-1);
      A.deleteColumn();
    }else{
      rankCounter+=1;
      while(true){
        let i2=i1+1;
        for(let i=i1+1;i<A.low.length;i++){
          if(A.low[i][0]===1)break;
          i2++;
        }
        if(i2===A.low.length)break;
        A.low[i2]=XOR(A.low[i1],A.low[i2]);
      }
      A.swapLow(i1,A.low.length-1);
      A.deleteLow();
    }
  }
  var r=rankCounter;
  var ans=Math.pow(2,N+M-1)-Math.pow(2,Math.min(M,N)-r+Math.max(M,N)-1);
  console.log(ans);
}

function xor(a,b){
  return a===b?0:1;
}

function XOR(arr1,arr2){
  return arr1.map((x,i)=>xor(x,arr2[i]));
}

function Matrix(N,M,elements){//elements are given as concated lows.
  var A=this;
  A.low=[];
  for(let i=0;i<N;i++)A.low[i]=[];
  for(let i=0;i<N;i++)for(let j=0;j<M;j++){
    A.low[i][j]=elements[i*M+j];
  }
}

function swap(arr,i1,i2){
  var a=arr[i1];
  var b=arr[i2];
  arr[i1]=b,arr[i2]=a;
}

Matrix.prototype.swapLow=function(i1,i2){
  var A=this;
  swap(A.low,i1,i2);
}

Matrix.prototype.deleteLow=function(){//delete the last low.
  var A=this;
  var L=A.low;
  L.pop();
}

Matrix.prototype.swapColumn=function(j1,j2){
  var A=this;
  for(let i=0;i<A.low.length;i++)
    swap(A.low[i],j1,j2);
}

Matrix.prototype.deleteColumn=function(){//delete the last Column.
  var A=this;
  var L=A.low;
  var N=L.length;
  if(L[0].length===1)A.low=[];
  for(let i=0;i<N;i++)
    L[i].pop();
}


Main(require('fs').readFileSync('/dev/stdin','utf8'));