import numpy as np N, P = map(int, input().split()) abc = [[int(_) for _ in input().split()] for _ in range(N)] dp = np.zeros([N+1, P+10], dtype=int) for i in range(1, N+1): dp[i][0] = dp[i-1][0] + abc[i-1][0] dp[i][1] = min(dp[i-1][1] + abc[i-1][0], dp[i-1][0] + abc[i-1][1]) dp[i][2:] = np.minimum(np.minimum(dp[i-1][:-2]+abc[i-1][2], dp[i-1][1:-1]+abc[i-1][1]), dp[i-1][2:]+abc[i-1][0]) print(dp[N][P]/N)