#include <bits/stdc++.h>
# define endl            '\n'
# define clr(x,a)        memset(x,a,sizeof(x))
# define vi              vector<int>
# define all(a)          a.begin(), a.end()
# define deb(x)          cout<<#x<<"=="<<x<<endl;
# define pb              push_back
# define sc              scanf
# define pr              printf
# define tc              int t; cin>>t; while(t--)
# define rev(s)          reverse(s.begin(),s.end())
# define linija          cout<<"___________\n";
using namespace std;
typedef long long ll;
const int mxN=300005, mxM=200005, LOG=25, inf=1e8;
const ll mod=998244353;
template<typename T> T nzd(T a, T b){if(b==0) return a;else return nzd(b, a%b);}
template<typename T> T nzs(T a, T b){return(a*(b/nzd(a,b)));}
template<typename T> T stepenuj(T e, T n){T x=1,p=e;while(n){if(n&1)x=(x*p)%mod;p=(p*p)%mod;n>>=1;}return x;}
template<typename T> inline T na2(T x){return x*x;}
//2^29 <= 1e9
int n, m, a[1505][1505], niz[5000], br;

int main(){
   freopen("in.txt", "r", stdin);
   cin >> n >> m;
   for(int i = 1; i <= n; i++){
      for(int j = 1; j <= m; j++){
         sc("%d", &a[i][j]);
      }
   }

   if(n==1){
      for(int i = 1; i <= m; i++){
         br++;
         niz[br] = a[1][i];
//         cout << a[1][i]<<endl;
      }
//      deb(br);
//      cout <<"ovfde je\n";
   }
   else if(m==1){
      for(int i=1; i<=n; i++){
         br++;
         niz[br] = a[i][1];
      }
   }
   else{
      int r1, c1, r2, c2;
      r1=2;
      c1=1;
      r2=1;
      c2=2;
      niz[1]=a[1][1];
      br = 1;
      while(c1<m){
         br++;
         niz[br] = (a[r1][c1] ^ a[r2][c2]);
         if(r1==n) c1++;
         else r1++;

         if(c2==m) r2++;
         else c2++;
      }

      br++;
      niz[br] = a[n][m];
   }

//   for(int i = 1; i<=br; i++) cout<<niz[i]<<" ";
//   cout << endl;

   ll sumapre = 0, sumaposle;
   for(int i = 1; i <=br; i++) sumapre+=niz[i];
//   deb(sumapre);

   for(int i = 0; i <= 29; i++){
      sumaposle = 0;
//      cout<<"na "<<i<<endl;
      for(int j=1; j<=br; j++){
         niz[j] ^= (1<<i);
         sumaposle += niz[j];
      }
      if(sumaposle > sumapre){
         for(int j=1; j<=br; j++){
            niz[j] ^= (1<<i);
         }
      }
      else sumapre = sumaposle;
   }

   cout<<sumapre<<endl;

	return 0;
}