import Control.Monad
import Control.Applicative
import Data.List
  
main :: IO ()
main = do
  n <- readLn :: IO Int
  if n == 0
    then return ()
    else do
    ns <- getData n
    let ans = solve ns
    if null ans then putStrLn "NA"
                else mapM_ print ans
    main
  
getData :: Int -> IO [(Int, Int)]
getData n = replicateM n $ do
  [i, x, y] <- map read . words <$> getLine :: IO [Int]
  return (i, x * y)

solve :: [(Int, Int)] -> [Int]
solve ns = map fst
           $ filter ((>= 1000000) . snd)
           $ map (\ls -> (fst (head ls), sum (map snd ls)))
           $ groupBy (\n1 n2 -> fst n1 == fst n2)
           $ sort ns