#include <iostream>
#include <set>

using namespace std;

int main() {
    int n, m;
    cin>>n>>m;
    int red[m];
    int max_br = INT_MIN;
    int max_zbir = 0;
    for(int j = 0; j < n; j++) {
        for(int i = 0; i < m; i++) {
            cin>>red[i];
            if(red[i] > max_br) {
                max_br = red[i];
                max_zbir += red[i];
            }
        }
    }
    set<int> iskorisceni;
    while(true) {
        int zbir = 0;
        int novi_max = INT_MIN;
        if(iskorisceni.count(max_br) >= 1) break;
        for(int i = 0; i < m; i++) {
            red[i] = red[i] ^ max_br;
            zbir += red[i];
            if(red[i] > novi_max) novi_max = red[i];
        }
        iskorisceni.insert(iskorisceni.begin(), max_br);
        if(zbir < max_zbir) max_zbir = zbir;
        if(novi_max <= max_br) break;
        else max_br = novi_max;
    }
    cout<<max_zbir;
    return 0;
}