#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn =5e5+10;
const int mod=1e9+7;
int w, h;
LL ans=0;
LL all[1000]={};
LL d[1000]={};
LL C[1000]={};
LL c[1000][1000];
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>w>>h;
if(h>=w){
all[1]=all[0]=C[0]=C[1]=1;
for(int i=2; i<=w; i++) all[i]=all[i-1]+all[i-2], all[i]%=mod;
for(int i=2; i<=w; i++){
LL p=1;
for(int j=1; j<=h; j++) p*=all[i], p%=mod;
all[i]=p;
for(int j=1; j<i; j++) d[i]+=C[j]*all[i-j]%mod, d[i]%=mod;
C[i]= ((all[i]-d[i])%mod + mod) % mod;
}
cout<<C[w];
}else{
for(int i=0; i<=h; i++){
c[i][0]=c[i][i]=1;
for(int j=1; j<i; j++) c[i][j]=c[i-1][j-1]+c[i-1][j], c[i][j]%=mod;
}
vector<LL> d(h+1, 0);
vector<LL> e(h+1, 0);
for(int i=1; i<=h; i++) d[i]=c[h][i];
for(int k=1; k<w-1; k++){
e.assign(h+1, 0);
for(int i=1; i<=h; i++)
for(int j=1; i+j<=h; j++) e[j]+=d[i]*c[h-i][j]%mod, e[j]%=mod;
swap(e, d);
}
for (int i = 0; i <= h; i++) {
ans += d[i];
ans%=mod;
}
cout<<ans;
}
return 0;
}