#include using namespace std; #include using namespace atcoder; using ll = long long; int dp[11][101][10001]; int is[11][101][10001]; int A[3],B[3],C[3]; int Db,Dc; void solve(){ int st = 0; using TUP = tuple; vector vtB; { st = Db; for(int i0 = 0;i0*1000<=st;i0++){ for(int i1 = 0;i1*100+i0*1000 <= st;i1++){ int i2 = st - i0 * 1000 - i1 * 100; //cerr< vtC; { st = Dc; for(int i0 = 0;i0*1000<=st;i0++){ for(int i1 = 0;i1*100+i0*1000 <= st;i1++){ int i2 = st - i0 * 1000 - i1 * 100; //cerr<=0;i--){ for(int i0 = 0;i0*1000<=i;i0++){ for(int i1 = 0;i1*100+i0*1000<=i;i1++){ int i2 = i - i0 * 1000 - i1 * 100; if(is[i0][i1][i2]==0)continue; //cerr<> A[i]; cin >> Db; for(int i = 0;i<3;i++)cin >> B[i]; cin >> Dc; for(int i = 0;i<3;i++)cin >> C[i]; solve(); }