#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, K, b = 1; cin >> n >> K; vector P(n), A(n), B(n); for(int i = 0; i < n; i++)cin >> P[i] >> A[i] >> B[i]; if(accumulate(A.begin(), A.end(), 0) <= 60){ cout << 1 << ' ' << 1 << ' ' << 1 << '\n'; return 0; } if(accumulate(B.begin(), B.end(), 0) > 60){ cout << -1 << '\n'; return 0; } vector idx; for(int i = 0; i < n; i++){ for(int j = K + 1; j < P[i]; j++)idx.push_back(i); b *= P[i] - K; } int m = idx.size(), mx = K + 2; double ans = K + 2; vector dp(1 << m); vector dp2(1 << m); dp[0] = 1; dp2[0] = K + 2; for(int i = 0; i < (1 << m); i++){ if(!dp2[i])continue; int S = 0, S2 = 0; mx = max(mx, dp2[i]); for(int j = 0; j < m; j++){ if((i >> j & 1) || (S2 >> idx[j] & 1))continue; S2 |= 1 << idx[j]; S |= 1 << j; } auto f = [&](int S){ array cnt{}; int tim = 0, S2 = 0, res = 1; for(int j = 0; j < m; j++){ if(~i >> j & 1)cnt[idx[j]]++; if(S >> j & 1)S2 |= 1 << idx[j]; } for(int j = 0; j < n; j++){ if(S2 >> j & 1){ tim += A[j]; res *= cnt[j]; }else{ tim += B[j]; res *= P[j] - K - cnt[j]; } } return make_pair(tim, res); }; for(int T = S; T > 0; T = (T - 1) & S){ auto pa = f(T); if(pa.first > 60){ double v = double(dp[i] * pa.second) / b; ans += v; dp[i | T] += v; dp2[i | T] = max(dp2[i | T], dp2[i] + 1); } } } cout << fixed << setprecision(15) << K + 2 << " " << mx << " " << ans << '\n'; }