FWT裸题,写了下模板
#include<cstdio>
#define ll long long
#define r register int
#define MN (1<<20)
#define MOD 1000000007
char s[MN+];
int n,ans,f[MN+];
ll a[MN+];
inline int mod(int x){return x<MOD?x:x-MOD;}
void fwt(int v)
{
for(r i=;i<n;++i)for(r j=,x;j<<<n;++j)if(x=j^(<<i),j&(<<i))
a[x]=a[x]+a[j],a[j]=(a[x]-a[j]-a[j])/(v?:),a[x]/=v?:;
}
int main()
{
scanf("%d%s",&n,s);
for(r i=;i<<<n;++i)a[i]=s[i]-'';fwt();
for(r i=;i<<<n;++i)a[i]*=a[i];fwt();
for(r i=f[]=;i<<<n;++i)f[i]=mod(f[i>>]<<(i&));
for(r i=;i<<<n;++i)ans=(ans+1LL*a[i]*f[i^((<<n)-)])%MOD;
printf("%d",3LL*ans%MOD);
}