#include<bits/stdc++.h> usingnamespacestd; constint mod = 1e9; intget(){ char ch; int v,f=0; while (!isdigit(ch=getchar())) if (ch=='-') break; if (ch=='-') f=1;else v=ch-48; while (isdigit(ch=getchar())) v=v*10+ch-48; return f?-v:v; } int n; typedeflonglong ll; constint maxn =300; ll mat[maxn][maxn], M,sz; inttrans(int X, int Y) { int dp[10][2]; dp[0][0]=1, dp[0][1]=0; for (int i = 1, bin = 1; i <= n; i++, bin <<= 1) { int x = ((X & bin) > 0), y = ((Y & bin) > 0); if (y == 1) { dp[i][0] = dp[i-1][1] + (x==0?dp[i-1][0]:0); dp[i][1] = dp[i-1][0]; } else { dp[i][0] = dp[i-1][0]; dp[i][1] = 0; } } return dp[n][0]; } longlong tmp[maxn][maxn],Map[maxn][maxn]; intksm(ll m[maxn][maxn],ll t,int N){ memcpy(Map,m,sizeof(Map)); t--; while (t){ if (t%2==1){ for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) tmp[i][j]=0;//清空临时数组 for (int i=1;i<=N;i++) for (int k=1;k<=N;k++) if (m[i][k]) for (int j=1;j<=N;j++) tmp[i][j]+=m[i][k]*Map[k][j]%mod,tmp[i][j]%=mod; //矩阵乘法 for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) Map[i][j]=tmp[i][j]; //赋值到原数组 } for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) tmp[i][j]=0;//清空临时数组 for (int i=1;i<=N;i++) for (int k=1;k<=N;k++) if (m[i][k]) for (int j=1;j<=N;j++) tmp[i][j]+=m[i][k]*m[k][j]%mod,tmp[i][j]%=mod; for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) m[i][j]=tmp[i][j]; t>>=1;
}
ll ans=0; for (int i=1;i<=N;++i) ans=(ans+Map[N][i])%mod; return ans; } intmain(){ cin >> n >> M; sz = (1 << n); for (int i = 1; i <= sz; i++) for (int j = 1; j <= sz; j++) { mat[i][j] = trans(i-1, j-1); } cout << ksm(mat,M,sz)<<endl; return0; }