list = [] alp = ["N","U","P","C"] [1,2].repeated_permutation(4) do |a| l = [] for i in 0...4 if a[i] == 1 l << alp[i] elsif a[i] == 2 l << alp[i] (l.dup).each{|ll|l << ll} end end list << l.join end list.sort! n = gets.to_i puts list[n-1]