#include #include #include using namespace atcoder; using mint = modint; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int dp[11][101][10001]; int main(){ vector a(3); rep(i,3)cin>>a[i]; int db; cin>>db; vector b(3); rep(i,3)cin>>b[i]; int dc; cin>>dc; vector c(3); rep(i,3)cin>>c[i]; rep(i,11){ rep(j,101){ rep(k,10001)dp[i][j][k] = -Inf; } } priority_queue>> Q; dp[a[0]][a[1]][a[2]] = 0; Q.emplace(a[0]*1000+a[1]*100+a[2],a); while(Q.size()>0){ vector t = Q.top().second; Q.pop(); rep(i,t[0]+1){ rep(j,t[1]+1){ if(i*1000+j*100>db)break; int k = db - i*1000 - j*100; if(t[2]dc)break; int k = dc - i*1000 - j*100; if(t[2]