main :: IO ()
main = do
    _ <- getLine
    widths <- readInts <$> getLine
    interact $ lines >>> map (readInts >>> solve widths >>> show) >>> unlines
main :: IO ()
main = do
    _ <- getLine
    widths <- readInts <$> getLine
    interact $ lines >>> map (readInts >>> solve widths >>> show) >>> unlines
main = do
    _ <- getLine
    widths <- readInts <$> getLine
    interact $ lines >>> map (readInts >>> solve widths >>> show) >>> unlines