Help me in solving SMXR problem

My issue

If we take each submatrices of 2X2 with all elements 0 and fill each of them with 1 one by one, then we will receive the value for each submatrix as 6. There will be NM/4 such submatrices and for each of them the solution will be 6. So according to my analysis it must be 6(nm)/4=3(n*m)/2.

My code

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

int main() 
{
	int t;
	cin>>t;
	while(t--)
	{
	    long long int n,m,a=0;
	    cin>>n>>m;
	    if(n%2!=0 && )
	    {
	        a+=(m/2)*(m/2+1)+(m/2)*(m/2-1);
	    }
	    a-=n+m;
	    cout<<3*(n*m)/2+a<<endl;
	}
	return 0;
}

Problem Link: Sum of Xors Practice Coding Problem

pls ignore the if condition and calculation of ‘a’.

your method can be applied if n or m =2
but if n and m >=4
we can get 0 for k value even like for 4*4 matrix and k=6
1100
1010
0110
0000
ugliness=0