import java.util.*; public class Main { static int[][] prises; static int[][] dp; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p = sc.nextInt(); prises = new int[3][n + 1]; dp = new int[p + 1][n + 1]; for (int i = 1; i <= n; i++) { for (int j = 0; j < 3; j++) { prises[j][i] = sc.nextInt(); } } double sum = dfw(p, n); System.out.println(sum / n); } static int dfw(int point, int idx) { if (point < 0) { return Integer.MAX_VALUE / 2 + 1; } if (idx == 0) { return 0; } if (dp[point][idx] != 0) { return dp[point][idx] ; } int min = dfw(point - 3, idx - 1) + 1; for (int j = 0; j < 3; j++) { min = Math.min(min, prises[j][idx] + dfw(point - j, idx - 1)); } dp[point][idx] = min; return min; } }