#include //#include using namespace std; // using namespace atcoder; // using mint = modint1000000007; // const int mod = 1000000007; // using mint = modint998244353; // const int mod = 998244353; // const int INF = 1e9; // const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i, l, r) for (int i = (l); i < (r); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; --i) #define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define P pair template inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int s, t, n; cin >> s >> t >> n; vectorp(3), a(3), b(3); rep(i, 3)cin >> p[i] >> a[i] >> b[i]; vector dp(n + 1, vector(t + 1)); vector dp2(n + 1, vector>(t + 1)); dp[n][t] = 1; rrep(i, n)dp[i][t] = dp[i + 1][t] * 100; rrep(i, n) { int ni = i + 1; rep2(j, 1, t) { rep2(x, 1, j + 1) { long long tmp = 0; rep(y, 3) { long long nj = j - x + (a[y] * x / b[y]); chmin(nj, t); chmax(nj, 0); tmp += dp[ni][nj] * p[y]; } if (chmax(dp[i][j], tmp)) dp2[i][j].clear(); if (dp[i][j] == tmp)dp2[i][j].push_back(x); } } } long long val = dp[0][s]; rep(i, n - 1)val /= 100; cout << val << endl; cout << dp2[0][s].size() << endl; for (auto e : dp2[0][s]) cout << e << " "; cout << endl; return 0; }