#include using namespace std; #define all(x) (x).begin(), (x).end() template void check_min(T &a, const T &b){ a = (a < b) ? a : b; } template void check_max(T &a, const T &b){ a = (a > b) ? a : b; } typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); freopen("apartments.in", "r", stdin); freopen("apartments.out", "w", stdout); int t; cin >> t; while(t--){ int m, l, a1, a2, b1, b2; bool answered = false; cin >> m >> l >> a1 >> a2 >> b1 >> b2; for(int i = 4; i >= 1 && !answered; --i){ for(int s1 = 1; s1 <= i && !answered; ++s1){ for(int s2 = 1; s2 <= i && !answered; ++s2){ bool ok = true; int money = m * (a1 + a2), naem = a1 + a2; for(int j = 1; j <= i; ++j){ if(s1 == j){ money += b1; naem -= a1; } if(s2 == j){ money += b2; naem -= a2; } if(money < l){ ok = false; break; } money -= l; money += 12 * naem; } if(ok){ cout << i << " " << m + (s1 - 1) * 12 << " " << m + (s2 - 1) * 12 << "\n"; answered = true; } } } } if(!answered) cout << "0 -1 -1\n"; } }