local ior = io.input() local n, p = ior:read("*n", "*n") local t = {} for i = 1, p + 5 do t[i] = 0 end t[1] = 0 local curmax = 1 for i_n = 1, n do local a, b, c = ior:read("*n", "*n", "*n") t[curmax], t[curmax + 1], t[curmax + 2], t[curmax + 3] = t[curmax] + a, t[curmax] + b, t[curmax] + c, t[curmax] + 1 for i = curmax - 1, 1, -1 do t[i + 3] = math.min(t[i + 3], t[i] + 1) t[i + 2] = math.min(t[i + 2], t[i] + c) t[i + 1] = math.min(t[i + 1], t[i] + b) t[i] = t[i] + a end curmax = math.min(p + 1, 3 * i_n + 1) end print(string.format("%.8f", t[p + 1] / n))