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[p + 5]; Arrays.fill(dp, Integer.MAX_VALUE / 2); dp[3] = 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) + 3; j >= 3; j--) { dp[j] = Math.min(Math.min(dp[j] + zero, dp[j - 1] + one), Math.min(dp[j - 2] + two, dp[j - 3] + 1)); } } System.out.println(dp[p + 3] / (double)n); } }