#include #include #include #include #include #include #define maxn 12000 #define maxm 4200 #define eps 1e-8 #define p 1000000007 using namespace std; struct mat { long long m[130][130]; void clear() { memset(m,0,sizeof(m)); } }I,S,T; int n,m,num,mxbit; int a[10],b[10]; mat mult(mat a,mat b) { mat c; c.clear(); for (int i=0;i<=mxbit;i++) for (int j=0;j<=mxbit;j++) for (int k=0;k<=mxbit;k++) c.m[i][j]=(c.m[i][j]+(a.m[i][k]*b.m[j][k])%p)%p; return c; } mat pow(mat e,int k) { mat mid=I; while (k) { if (k&1) mid=mult(mid,e); k=k>>1; e=mult(e,e); } return mid; } bool trans(int x,int y) { for (int i=0;i>i)&1; b[i]=(y>>i)&1; } //for (int i=0;i0 && b[i-1] && !a[i-1]) return 0; if (i