import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int p = sc.nextInt(); int[][] dp = new int[n + 1][p + 1]; for (int[] arr : dp) { Arrays.fill(arr, Integer.MAX_VALUE / 2); } dp[0][0] = 0; for (int i = 1; i <= n; i++) { int zero = sc.nextInt(); int one = sc.nextInt(); int two = sc.nextInt(); for (int j = Math.min(p, i * 3); j >= 0; j--) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j] + zero); if (j - 1 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + one); } if (j - 2 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 2] + two); } if (j - 3 >= 0) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 3] + 1); } } } System.out.println(dp[n][p] / (double)n); } }