import random import time nn, m = map(int,input().split()) d = [] st = time.time() n = 0 ans = 0 nans = 0 for i in range(nn): a, b, p = map(int,input().split()) if a <= b: ans += 1 / a nans += 1 / a elif p == 1: ans += 1 / b nans += 1 / b else: d.append((a, b, p)) n += 1 assert(m == 40) assert(n == 12) d.sort(key= lambda x:(-(x[0]-x[1])/(x[1]*x[0]*x[2]), x[0])) dp = [0.0] * (n+1) dp[0] = 1.0 for i in range(m): ndp = [0.0] * (n+1) for j in range(n+1): tar = 1.0 for k in range(j, n): ndp[k] += dp[j] * tar * (1 - 1/d[k][2]) tar *= 1/d[k][2] ndp[n] += dp[j] * tar dp = ndp tmp = 0.0 for i in range(n): tmp += 1 / d[i][0] #print(tmp) for i in range(n+1): ans += tmp * dp[i] if i < n: tmp -= 1 / d[i][0] tmp += 1 / d[i][1] #print(tmp, dp[i]) nnans = nans print(ans)