#include <iostream>
#define int long long
using namespace std;
int v[1000005];
int32_t main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    int mx=0;
    for(int mask=0;mask<(1<<n);mask++){
        int nr=0;
        for(int bit=0;bit<n;bit++){
            if(mask&(1<<bit)){
                nr++;
                if(bit==0){
                    nr=-1;
                    break;
                }
            }
        }
        if(nr!=k-1) continue;
        int ans=(1<<n)-1;
        int sau=0;
        for(int bit=0;bit<n;bit++){
            if(mask&(1<<bit)){
                ans=ans&sau;
                cout<<bit<<" "<<sau<<endl;
                sau=v[bit+1];
            }
            sau=sau|(v[bit+1]);
        }
        ans=ans&sau;
        cout<<n<<" "<<sau<<endl<<endl;
        mx=max(mx,ans);
    }
    cout<<mx;
    return 0;
}
