import Control.Monad
import Control.Applicative

insert :: Int -> [Int] -> [Int]
insert n [] = [n]
insert n (m:ns)
  | n < m = n : m : ns
  | n == m = n : ns
  | True = m : insert n ns

combs' :: Int -> Int -> [Int] -> [Int]
combs' n max [] = if n <= max then combs' n max [n] else []
combs' n max (m:ns) =
  if m + n <= max
    then m : (combs' n max $ insert (m + n) ns)
    else m : ns

combs'' :: [Int] -> Int -> [Int] -> [Int]
combs'' [] _ ms = ms
combs'' (n:ns) max ms = combs'' ns max $ combs' n max ms

combs ns max = combs'' ns max [0]

is_prime :: Int -> Bool
is_prime n = all (\m -> mod n m /= 0) [2..n-1]

v0202' [] = "NA"
v0202' [0] = "NA"
v0202' [0,1] = "NA"
v0202' (n:ns) = if is_prime n then show n else v0202' ns

v0202 ns max = v0202' (reverse (combs ns max))

while :: (Monad m) => (a -> Bool) -> m a -> m [a]
while p f = do
  a <- f
  if p a then fmap (a :) (while p f) else return []

routine :: IO (Int, Int, [Int])
routine = do
  [n, max] <- map read . words <$> getLine
  if (n, max) /= (0, 0)
    then do costs <- replicateM n readLn
            return (n, max, costs)
    else return (0, 0, [])

main = do
  inps <- while (\(a, b, c) -> c /= []) routine
  mapM_ (\(n,max,costs) -> putStrLn $ v0202 costs max) inps