# 分析：

#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdio>

#define MX 3000004
#define ls tre[node].s[0]
#define rs tre[node].s[1]

using namespace std;

typedef struct trrr
{
int fa,s[2],x,ans,num,dep;
}trie;

trie tre[MX];
int n,m,a[MX],b[MX];
int fl[MX],fr[MX];
int nn;

int f(int x)
{
return ((x<<1)%(1<<n)+(x<<1)/(1<<n));
}

void input()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)scanf("%d",&a[i]);
}

void insrt(int node,int len,int x,int fa)
{
tre[node].fa=fa,tre[node].dep=len;
if(len==-1)return;
int nxp=!!(x&(1<<len));
if(tre[node].s[0]&&nxp==0)tre[tre[node].s[0]].x=nxp,insrt(tre[node].s[0],len-1,x,node);
else if(tre[node].s[1]&&nxp==1)tre[tre[node].s[1]].x=nxp,insrt(tre[node].s[1],len-1,x,node);
else
{
tre[node].s[nxp]=++nn;
tre[tre[node].s[nxp]].x=nxp;
insrt(tre[node].s[nxp],len-1,x,node);
}
}

void build()
{
for(int i=1;i<=m;i++)fl[i]=fl[i-1]^a[i];
for(int i=m;i>=1;i--)fr[i]=fr[i+1]^a[i];
for(int i=0;i<=m;i++)b[i]=f(fl[i])^fr[i+1];
for(int i=0;i<=m;i++)insrt(0,n-1,b[i],0);
}

void dfs(int node)
{
if(ls)dfs(ls);
if(rs)dfs(rs);
if(tre[node].s[0]==0&&tre[node].s[1]==0)
{
tre[node].ans=0;
tre[node].num=1;
}
else if(tre[node].s[0]==0&&tre[node].s[1])
{
tre[node].ans=tre[rs].ans|(1<<tre[node].dep);
tre[node].num=tre[rs].num;
}
else if(tre[node].s[0]&&tre[node].s[1]==0)
{
tre[node].ans=tre[ls].ans|(1<<tre[node].dep);
tre[node].num=tre[ls].num;
}
else
{
tre[node].ans=max(tre[tre[node].s[0]].ans,tre[tre[node].s[1]].ans);
if(tre[ls].ans<tre[rs].ans)tre[node].num=tre[rs].num;
else if(tre[ls].ans>tre[rs].ans)tre[node].num=tre[ls].num;
else tre[node].num=tre[ls].num+tre[rs].num;
}
}

int main()
{
freopen("big.in","r",stdin);
freopen("big.out","w",stdout);
input();
build();
dfs(0);
cout<<(tre[0].ans)<<endl<<(tre[0].num)<<endl;
return 0;
}