import Control.Applicative string2int str = read str :: Int tetra n | n == 1 || n == 2 || n == 3 = 0 | n == 4 = 1 | otherwise = tetra (n-1) + tetra (n-2) + tetra (n-3) + tetra (n-4) ans n = do ss <- getLine let n = string2int ss print $ mod (tetra n) 17 main :: IO () main = do ss <- getLine let q = string2int ss mapM_ ans $ enumFromTo 0 q