import Control.Monad

main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      y <- readLn
      ls <- replicateM n getLine
      let ls' = map (map read . words) ls
          top1 = head (sort (filter (\[_,_,c] -> c == 1) ls'))
          top2 = head (sort (filter (\[_,_,c] -> c == 2) ls'))
      print $ solve y top1 top2
      main
      
sort :: [[Int]] -> [[Int]]
sort [] = []
sort ([b,r,t]:xs) = (sort higher) ++ [[b,r,t]] ++ (sort lower)
  where
    higher = filter (\[_,b,_] -> b >= r) xs
    lower = filter (\[_,b,_] -> b < r) xs

solve :: Int -> [Int] -> [Int] -> Int
solve y [b1,r1,t1] [b2,r2,t2]
  | pro1 >= pro2 = b1
  | otherwise = b2
  where
    pro1 = (100 + y * r1) * (pow 100 (y-1))
    pro2 = pow (100 + r2) y
    pow :: Int -> Int -> Int
    pow d n = pow' d n 1
      where
        pow' :: Int -> Int -> Int -> Int
        pow' _ 0 a = a
        pow' d n a = pow' d (n-1) (a * d)