import numpy as np N, P = map(int, input().split()) dp = np.zeros(P + 1, dtype=int) for _ in range(N): a, b, c = map(int, input().split()) new_dp = dp + a new_dp[1:] = np.minimum(new_dp[1:], dp[:-1] + b) new_dp[2:] = np.minimum(new_dp[2:], dp[:-2] + c) new_dp[3:] = np.minimum(new_dp[3:], dp[:-3] + 1) dp = new_dp print(dp[P] / N)