import System.IO
import Data.List
import Control.Monad
theList = [4,5,7,9,11,13,17,19,23]
as = concat $ snd $ mapAccumL step 1 theList
where
step b l = (b+l, take (pred l) [succ b..] ++ [b])
main = do
print 108
putStrLn $ unwords $ map show as
hFlush stdout
bs <- map read . words <$> getLine
let ans = phase2 bs
print ans
phase2 :: [Int] -> Int
phase2 bs = ans
where
bs1 = map (bs !!) $ init $ scanl (+) 0 theList
rs = zipWith (-) bs1 $ scanl (+) 1 theList
Just (ans,_) = crt $ zip rs theList
-- @gotoki_no_joe
crt :: [(Int,Int)] -> Maybe (Int,Int)
crt = foldM step1 (0,1)
where
step1 (r0,m0) (r1,m1)
| m0 < m1 = step2 (mod r1 m1) m1 r0 m0
| otherwise = step2 r0 m0 (mod r1 m1) m1
step2 r0 m0 r1 m1
| mod m0 m1 == 0 = if mod r0 m1 == r1 then Just (r0, m0) else Nothing
| r /= 0 = Nothing
| otherwise = Just (r0 + x * m0, m0 * u)
where
(g,im) = invGCD m0 m1
(q, r) = divMod (r1 - r0) g
u = div m1 g
x = mod (mod q u * im) u
invGCD :: Int -> Int -> (Int, Int)
invGCD a b
| a1 == 0 = (b, 0)
| otherwise = loop b a1 0 1
where
a1 = mod a b
loop s 0 m0 m1 = (s, if m0 < 0 then m0 + div b s else m0)
loop s t m0 m1 = loop t (s - t * u) m1 (m0 - m1 * u)
where
u = div s t