{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeApplications #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.IntSet as Set
import qualified Data.List as L
import System.Random

main :: IO ()
main = do
  [d] <- readInts
  scoreTable <- readInts
  replicateM d readInts >>= output d . solve
 
solve :: [[Int]] -> _
solve xs = xs
 
output :: Int -> _ -> IO ()
output d _ = mapM_ (print . (+1) . flip mod 26 . read @Int) $ take d $ f digs
  where
    f (x1:x2:xs) = [x1,x2] : f xs

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

-- リストのhead側を正格評価する版
zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith' f (x:xs) (y:ys) = let z = f x y
                           in z `seq` (z : zipWith' f xs ys)

-- zipWithを使った版（正格評価）
fib' :: [Int]
fib' = 0 : 1 : zipWith' (+) fib' (tail fib')

pi_ :: [Integer]
pi_ = g(1,0,1,1,3,3) where
  g (q,r,t,k,n,l) =
   if 4*q+r-t < n*t
    then n : g (10*q, 10*(r-n*t), t, k, div (10*(3*q+r)) t - 10*n, l)
    else g (q*k, (2*q+r)*l, t*l, k+1, div (q*(7*k+2)+r*l) (t*l), l+2)
 
digs :: [Char]
digs = drop 2 $ insertPoint digs'
  where insertPoint (x:xs) = x:'.':xs
        digs' = map (head . show) pi_