loop do
  n = gets.to_i
  break if n == 0

  tw = Hash.new(0)
  n.times do
    m, a, b = gets.split(' ').map(&:to_i)
    tw[a] += m
    tw[b] += -1*m
  end

  sum = 0
  flag = true
  tw.sort_by{ |k,v| k }.each do |ti,we|
    sum += we
    if sum > 150
      flag = false
      break
    end
  end
  puts flag ? "OK" : "NG"
end