import java.util.*; import java.io.*; public class Main { static HashMap[] dp; static int[][] contests; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int n = Integer.parseInt(first[0]); int p = Integer.parseInt(first[1]); dp = new HashMap[n + 1]; contests = new int[n + 1][3]; for (int i = 1; i <= n; i++) { String[] line = br.readLine().split(" ", 3); for (int j = 0; j < 3; j++) { contests[i][j] = Integer.parseInt(line[j]); } dp[i] = new HashMap(); } System.out.println(dfw(n, p) / (double) n); } static int dfw(int idx, int count) { if (count < 0) { return Integer.MAX_VALUE / 2; } if (idx <= 0) { return 0; } if (dp[idx].containsKey(count)) { return dp[idx].get(count); } int ans = Integer.MAX_VALUE; for (int i = 0; i < 3; i++) { if (count - i > (idx - 1) * 3) { continue; } ans = Math.min(ans, dfw(idx - 1, count - i) + contests[idx][i]); } ans = Math.min(ans, dfw(idx - 1, count - 3) + 1); dp[idx].put(count, ans); return ans; } }