import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.ByteString.Char8( readInt, tail)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int,Int)
	readPair = do
	    Just (l,rest) <- readInt <$> getLine'
	    let
		Just (r,_) = readInt $ B.tail rest

	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let
	searchRMinLMax 	= foldl update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) = (max lmax l, min rmin r)

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.ByteString.Char8( readInt, tail)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int,Int)
	readPair = do
	    Just (l,rest) <- readInt <$> getLine'
	    let
		Just (r,_) = readInt $ B.tail rest

	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let
	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) = (max lmax l, min rmin r)

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.ByteString.Char8( readInt, tail)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int,Int)
	readPair = do
	    Just (l,rest) <- readInt <$> getLine'
	    let
		Just (r,_) = readInt $ B.tail rest

	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max lmax l
		rmin' = min rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.Int( Int32)
import Data.Bits( (.|.), (.&.), xor, shiftR, complement)
import Data.ByteString.Char8( words, readInt)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int32,Int32)
	readPair = do
	    [Just (l,_) ,Just (r,_)] <- map readInt . B.words <$>
							    getLine'
	    return (fromIntegral l, fromIntegral r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max32 lmax l
		rmin' = min32 rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

branchFreeMinMax32:: Int32 -> Int32 -> Int32 -> Int32
branchFreeMinMax32 a b diff =
  let
    mask1 = shiftR	diff	    32
    mask2 = complement mask1

    lose_a = mask1 .&. a
    lose_b = mask2 .&. b
    loser = lose_a .|. lose_b

    ab = a `xor` b
    winner = loser `xor` ab
  in
    diff `seq`
    mask1 `seq` mask2 `seq`
    lose_a `seq` lose_b `seq` loser `seq`
    ab `seq`
    winner

max32, min32::Int32 -> Int32 -> Int32
max32 a b = branchFreeMinMax32 a b (a-b)
min32 a b = branchFreeMinMax32 a b (b-a)

{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Ord

sSpace w = span (/= ' ') w
toInt s = read s :: Int
toIntTup (a, b) = (toInt a, toInt b)

findMinMaxH :: Int -> Int -> Int -> IO((Int, Int))
findMinMaxH 0 cmin cmax = return (cmin, cmax)
findMinMaxH i !cmin !cmax = do
    w <- getLine
    let (newMax, newMin) = toIntTup $ sSpace w in
        findMinMaxH (i-1) (min cmin newMin) (max cmax newMax)

findMinMax :: Int -> IO((Int, Int))
findMinMax i = findMinMaxH i 10000000009 (-1)

main :: IO()
main = do
    chessCount <- getLine
    (cendmin, cstartmax) <- findMinMax $ toInt chessCount
    --print (cendmin, cstartmax)
    programCount <- getLine
    (pendmin, pstartmax) <- findMinMax $ toInt programCount
    --print (pendmin, pstartmax)
    print $ maximum [(pstartmax - cendmin), (cstartmax - pendmin), 0]

{-# OPTIONS_GHC -O3 #-}
{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}

import Control.Monad (foldM)
import Control.DeepSeq (force)

ffoldM a b f = foldM f b a

calc bn am an bm | am - bn <= 0 && an - bm <= 0 = 0
                 | otherwise = max (an - bm) (am - bn)

xmin a b | length a < length b = a
         | length b < length a = b
         | otherwise = min a b

xmax a b | length a > length b = a
         | length b > length a = b
         | otherwise = max a b

main = do
    (read -> n :: Int) <- getLine
    let (a, b) = (take 10 (repeat '9'), "")
    (map (read :: String -> Int) -> [bn, an]) <- ffoldM [1..n] [a, b] $ \[bn, an] _ -> do
        (words -> [c, c']) <- getLine
        return $ force [xmin bn c', xmax an c]
    (read -> m :: Int) <- getLine
    (map (read :: String -> Int) -> [bm, am]) <- ffoldM [1..m] [a, b] $ \[bm, am] _ -> do
        (words -> [c, c']) <- getLine
        return $ force [xmin bm c', xmax am c]
    putStrLn $ show (calc bn am an bm)

import Data.List
import Data.Maybe (fromJust)
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C

main :: IO()
main = print . solve . map (fst . fromJust . C.readInt) . C.words =<< B.getContents

solve :: [Int] -> Int
solve (n:a) = let (p, (_:q)) = splitAt (2 * n) a
                  (po, pe) = split p
                  (qo, qe) = split q
                  pomax = maximum po
                  pemin = minimum pe
                  qomax = maximum qo
                  qemin = minimum qe
                  int1 = if qomax > pemin then qomax - pemin else 0
                  int2 = if pomax > qemin then pomax - qemin else 0
              in max int1 int2

split :: [Int] -> ([Int], [Int])
split [] = ([], [])
split (x:y:s) = let (xs, ys) = split s in (x:xs, y:ys)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.ByteString.Char8( words, readInt)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int,Int)
	readPair = do
	    [Just (l,_) ,Just (r,_)] <- map readInt . B.words <$>
							    getLine'
	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max lmax l
		rmin' = min rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.ByteString.Char8( readInt, tail)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int,Int)
	readPair = do
	    Just (l,rest) <- readInt <$> getLine'
	    let
		Just (r,_) = readInt $ B.tail rest

	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max lmax l
		rmin' = min rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.Int( Int32)
import Data.Bits( (.|.), (.&.), xor, shiftR, complement)
import Data.ByteString.Char8( words, readInt)
import qualified Data.ByteString.Char8 as B
import System.IO( stdin)

main = do
    let
	getLine' = B.hGetLine stdin

    Just (n_, _) <- readInt <$> getLine'
    let
	readPair::IO (Int32,Int32)
	readPair = do
	    [Just (l,_) ,Just (r,_)] <- map readInt . B.words <$>
							    getLine'
	    return (fromIntegral l, fromIntegral r)

    chessPeriods_ <- replicateM n_ readPair

    Just (m_, _) <- readInt <$> getLine'
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max32 lmax l
		rmin' = min32 rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

branchFreeMinMax32:: Int32 -> Int32 -> Int32 -> Int32
branchFreeMinMax32 a b diff =
  let
    mask1 = shiftR	diff	    32
    mask2 = complement mask1

    lose_a = mask1 .&. a
    lose_b = mask2 .&. b
    loser = lose_a .|. lose_b

    ab = a `xor` b
    winner = loser `xor` ab
  in
    winner

max32, min32::Int32 -> Int32 -> Int32
max32 a b = branchFreeMinMax32 a b (a-b)
min32 a b = branchFreeMinMax32 a b (b-a)

import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')
import Data.Int( Int32)
import Data.Bits( (.|.), (.&.), xor, shiftR)

main = do
    n_ <- readLn::IO Int
    let
	readPair::IO (Int32,Int32)
	readPair = do
	    [l,r] <- map read . words <$> getLine
	    return (l,r)

    chessPeriods_ <- replicateM n_ readPair

    m_ <- readLn::IO Int
    progPeriods_ <- replicateM m_ readPair
    let

	searchRMinLMax 	= foldl' update (0,ten9)
	  where
	    update (lmax, rmin) (l,r) =
	      let
		lmax' = max32 lmax l
		rmin' = min32 rmin r
	      in
		lmax' `seq` rmin' `seq` (lmax', rmin')

	ten9 = 1000000000
	(lmaxChess, rminChess) = searchRMinLMax chessPeriods_
	(lmaxProg, rminProg) = searchRMinLMax progPeriods_

    print $ max 0$max (lmaxChess - rminProg) (lmaxProg - rminChess)

branchFreeMinMax32:: Int32 -> Int32 -> Int32 -> Int32
branchFreeMinMax32 a b diff =
  let
    mask1 = shiftR	diff	    32
    mask2 = shiftR (negate diff)    32

    lose_a = mask1 .&. a
    lose_b = mask2 .&. b
    loser = lose_a .|. lose_b

    ab = a `xor` b
    winner = loser `xor` ab
  in
    diff `seq`
    mask1 `seq` mask2 `seq`
    lose_a `seq` lose_b `seq` loser `seq`
    ab `seq`
    winner

max32, min32::Int32 -> Int32 -> Int32
max32 a b = branchFreeMinMax32 a b (a-b)
min32 a b = branchFreeMinMax32 a b (b-a)

import Control.Monad
import Data.List
import Data.Ord

sSpace w = span (/= ' ') w
toInt s = read s :: Int
toIntTup (a, b) = (toInt a, toInt b)

findMinMaxH :: Int -> Int -> Int -> IO((Int, Int))
findMinMaxH 0 cmin cmax = return (cmin, cmax)
findMinMaxH i cmin cmax = do
    w <- getLine
    let (newMax, newMin) = toIntTup $ sSpace w in
        findMinMaxH (i-1) (min cmin newMin) (max cmax newMax)

findMinMax :: Int -> IO((Int, Int))
findMinMax i = findMinMaxH i 1000000000000 (-1)

main :: IO()
main = do
    chessCount <- getLine
    (cendmin, cstartmax) <- findMinMax $ toInt chessCount
    programCount <- getLine
    (pendmin, pstartmax) <- findMinMax $ toInt programCount
    print $ maximum [(pstartmax - cendmin), (cstartmax - pendmin), 0]

{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Ord

sSpace w = span (/= ' ') w
toInt s = read s :: Int
toIntTup (a, b) = (toInt a, toInt b)

findMinMaxH :: Int -> Int -> Int -> IO((Int, Int))
findMinMaxH 0 cmin cmax = return (cmin, cmax)
findMinMaxH i !cmin !cmax = do
    w <- getLine
    let (newMax, newMin) = toIntTup $ sSpace w in
        findMinMaxH (i-1) (min cmin newMin) (max cmax newMax)

findMinMax :: Int -> IO((Int, Int))
findMinMax i = findMinMaxH i 100000009 (-1)

main :: IO()
main = do
    chessCount <- getLine
    (cendmin, cstartmax) <- findMinMax $ toInt chessCount
    programCount <- getLine
    (pendmin, pstartmax) <- findMinMax $ toInt programCount
    print $ maximum [(pstartmax - cendmin), (cstartmax - pendmin), 0]


f[]=[0]
f(x:y:t)=x:f t
f l=l
s(n:m:k:a)=minimum$k*(div m$n`div`2+1):f a
main=interact$show.s.map read.words

solve (n:m:k:as) = if odd n then min s q else 0
  where q = (k * (m `div` ((n + 1) `div` 2)))
        s = minimum $ map snd $ filter (odd.fst) $ zip [1..n] as

main = interact $ show.solve.map read.words

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

f (x:y:xs) = x:f xs
f (x:[]) = [x]
f ([]) = []

main = do
   [n, m, k] <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   xs <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   let ans = if even n
             then 0
             else let ratio = div (n+1) 2
                  in if m < ratio
                     then 0
                     else let mD = div m ratio
                              nds = min (mD*k) (minimum (f xs))
                          in nds
   print ans

module Main where

import Control.Monad
import Data.List

main = do
    [n, m, k] <- ( map read . words ) `liftM` getLine
    cells <- ( map read . words ) `liftM` getLine

    if even n
        then putStrLn "0"
        else do
            let m' = m `div` ((n+1) `div` 2)
                minTarget = minimum $ map snd $ filter (odd . fst) $ zip [1..] cells
                res = min minTarget (m' * k)
            putStrLn $ show res

s(n:m:k:as)|odd n=minimum$(k*(m`div`((n+1)`div`2))):(map snd$filter(odd.fst)$zip[1..n]as)|1>0=0
main=interact$show.s.map read.words

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

f (x:y:xs) = x:f xs
f (x:[]) = [x]
f ([]) = []

main = do
   [n, m, k] <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   xs <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   let ans = if even n
             then 0
             else let ratio = div (n+1) 2
                      mD = div m ratio
                      nds = minimum $ mD*k:f xs
                  in nds
   print ans

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

f (x:y:xs) = x:f xs
f (x:[]) = [x]
f ([]) = []

main = do
   [n, m, k] <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   xs <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   let ans = if even n
             then 0
             else let ratio = div (n+1) 2
                  in if m < ratio
                     then 0
                     else let mD = div m ratio
                              nT = min k (minimum (map (`div` mD) (f xs)))
                              rems = minimum $ map (`mod` mD) (f xs)
                          in if nT == k
                             then mD*nT
                             else mD*nT + rems
   print ans

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main = do
   [n, m, k] <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   xs <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   let ans = if even n
             then 0
             else let ratio = div (n+1) 2
                  in if m < ratio
                     then 0
                     else let mD = div m ratio
                              nT = min k (minimum (map (div mD) xs))
                          in mD*nT
   print ans

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

f (x:y:xs) = x:f xs
f (x:[]) = [x]
f ([]) = []

main = do
   [n, m, k] <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   xs <- map (fst.fromJust.BS.readInteger) . BS.words <$> BS.getLine
   let ans = if even n
             then 0
             else let ratio = div (n+1) 2
                  in if m < ratio
                     then 0
                     else let mD = div m ratio
                              nT = min k (minimum (map (`div` mD) (f xs)))
                          in mD*nT
   print ans


analyze a b = let
    ao = length (filter odd a)
    ae = length (filter even a)
    bo = length (filter odd b)
    be = length (filter even b)
  in (min ao be) + (min ae bo)
main = do
  getLine
  linea <- getLine
  lineb <- getLine
  putStrLn $ show $ analyze (map read (words linea)) (map read (words lineb))

{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

-- import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, m ] <- readInts
	as <- readInts
	bs <- readInts
	let
		count_odd = length . filter ( ( == 1 ) . ( `mod` 2 ) )
		a_odd = count_odd as
		a_even = n - a_odd
		b_odd = count_odd bs
		b_even = m - b_odd
	print $ min a_odd b_even + min a_even b_odd

main = getContents >>= print . solve . map (map read. words) . lines

solve [[x,y],xs,ys] = min ox (y - oy) + min oy (x - ox)
    where countOdd = length . filter odd
          (ox,oy) = (countOdd xs, countOdd ys)

import Data.List
main = do
  getLine
  (eas,oas) <- partition even . map read . words <$> getLine
  (ebs,obs) <- partition even . map read . words <$> getLine
  print $ min (length eas) (length obs) + min (length oas) (length ebs)

import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
import Data.Array

main = do
		[cl,kl]<- map read <$> words <$> getLine::IO [Int]
		c<- map read <$> words <$> getLine ::IO [Int]
		k<- map read <$> words <$> getLine ::IO [Int]
		let co = length $ filter odd c
		let ko = length $ filter odd k
		let ce = cl-co
		let ke = kl-ko
		print $ (min co ke) + (min ko ce)

import Data.List (partition)

process :: [Int] -> [Int] -> Int
process as bs = min (length ae) (length bo) + min (length ao) (length be)
    where
        (ao,ae) = partition odd as
        (bo,be) = partition odd bs

readInt :: String -> Int
readInt = read

main :: IO ()
main = do
    [n, m] <- fmap (map readInt.words) getLine
    as <- fmap (map readInt.words) getLine
    bs <- fmap (map readInt.words) getLine
    print $ process as bs


main = do
  [n, m] <- fmap (map read . words) getLine
  t <- mapM (\_ -> getLine) [1..n]
  let tt = map ((\[x, y] -> y / x) . map read . words) t
  print $ m / maximum tt

main = do
    [_,n] <- fmap (map read . words) getLine
    c <- fmap lines getContents
    print $ n * minimum [let [y,k] = (map read . words) l in y/k | l <- c]

import Data.List

f::[String]->Double
f (a:b:[])=(read a::Double) / (read b::Double)

main=do
     e1<-getLine
     es<-getContents
     let (n:m:[])=map read (words e1)::[Double]
         ans=head $ sort $ map f (map words (lines es))
     print $ ans*m

import Control.Applicative

main::IO ()
main=do
    [n,m]<-map read <$> words<$> getLine::IO [Double]
    a<-(map( map read) <$> map words<$> lines <$> getContents)::IO [[Double]]
    let b = minimum  $ map (\[z1,z2]-> z1/z2) a
    print $ b *m

main = interact $ show . solve . map read . tail . words
solve (m:ps) = minimum $ map (m*) $ go ps where
  go (a:b:ps) = a/b : go ps
  go [] = []

main = getContents >>= print . solve 10000.0 . map read . words

solve ans (0:_) = ans
solve ans (n:m:a:b:rst) = solve (min ans (m * a / b)) (n - 1:m:rst)

main=getContents>>=print.minimum.f.map read.words
f(_:m:l)=g l
  where
    g(x:y:z)=(x/y*m):g z
    g _ = []

import Control.Monad

main = do
    [n, m] <- fmap (fmap read . words) getLine
    l <- replicateM n $ fmap (fmap read . words) getLine
    print . minimum . map(\[a,b] -> (fromIntegral m)*a / b) $ l

import Control.Applicative
import Control.Monad
import Data.List

myread::String->Integer
myread= read

main = do
		[n,m]<-map read<$> words <$> getLine ::IO [Int]
		a<-map (\(a:b:c)-> fromIntegral a / (fromIntegral b)) <$> map (map (myread)) <$> map words <$> replicateM n getLine
		print $ (fromIntegral m)* minimum a


f :: Int -> IO ()
f 0 = return ()
f t = do
    n <- readLn :: IO Int
    putStrLn . unwords . map show $ n : [1..(n - 1)]
    f (t - 1)

main :: IO ()
main = do
    t <- readLn :: IO Int
    f t

import Control.Arrow ((>>>))

main =
  interact $
  words >>> drop 1 >>> map (read >>> solve >>> map show >>> unwords) >>> unlines

solve n = n : [1 .. n - 1]

import Data.List
import System.IO

main :: IO ()
main = do
    input <- getContents
    let output = solve input
    putStr output

solve :: String -> String
solve input = let n_list = tail $ map read $ words input
                  ans_list = map (\x -> foldl (\x y -> x ++ show y ++ " ") "" (x:[1..x-1])) n_list
              in foldl (\x y -> x ++ y ++ "\n") "" ans_list

solve n = [2..n] ++ [1]
main = interact $ unlines . map (unwords . map show) . map solve . tail . map read . words

import Data.List

solve :: Int -> [Int]
solve n = [2..n] ++ [1]

main :: IO ()
main = interact $ unlines . map (intercalate " " . map show) . map solve . tail . map read . words

{-# LANGUAGE GADTs, TemplateHaskell, DeriveFunctor, OverloadedStrings #-}

import Data.List
import qualified Data.ByteString.Char8 as B8
import Data.Maybe
import Data.Int
import Text.Printf
import Data.Function ( (&), on )
import Data.Functor
import Control.Arrow ((>>>))
import Control.Monad (forM_)
import Data.Char (isAlpha)

readIntB8 :: B8.ByteString -> Maybe Int
readIntB8 = B8.readInt >>> fmap fst

solve :: Int -> [Int]
solve n = [2 .. n] ++ [1]

main :: IO ()
main = do
    Just t <- B8.getLine <&> readIntB8
    forM_ [1 .. t] $ \_ -> do
        Just n <- B8.getLine <&> readIntB8
        let answer = solve n
        forM_ answer $ printf "%d "
        printf "\n"

import Control.Monad
import Data.List

main = do
  testCases <- read <$> getLine
  replicateM testCases $ do
    permutationLength <- read <$> getLine :: IO Int
    putStrLn $ mconcat $ intersperse " " $ map show $ specialPermutations permutationLength

specialPermutations :: Int -> [Int]
specialPermutations n
  | even n = reverse [1 .. n]
  | odd n = reverse $ mconcat [[1 .. (middle - 1)], [middle + 1, middle], [middle + 2 .. n]]
  where
    middle = div n 2 + 1

{-# LANGUAGE Safe #-}

import safe Control.Arrow ((>>>))
--import safe Data.List (sort)
import Data.List

main :: IO ()
main =  interact $  lines >>> drop 1 >>> tcio >>> unlines where
  tcio :: [String] -> [String]
  tcio [] = []
  tcio (l : rest) = (istoline . solve . linetoi) l : tcio rest
  itoline = show; istoline = unwords . (map itoline); isstolines = map istoline
  linetoi = read;

solve :: Int -> [Int]
solve n = (:) <$> last <*> init $ [1..n]

import Control.Monad ( replicateM )

main :: IO ()
main = do
    t <- readLn
    putStrLn . unlines . map (\n -> unwords . map show $ n : [1..(n - 1)]) =<< replicateM t (readLn :: IO Int)

import Control.Applicative ()

f :: Int -> IO ()
f 0 = return ()
f t = do
    n <- readLn
    putStrLn . unwords . map show $ n : [1..(n - 1)]
    f (t - 1)

main :: IO ()
main = f =<< readLn

f :: Int -> IO ()
f 0 = return ()
f t = do
    n <- readLn :: IO Int
    putStrLn . unwords . map show $ n : [1..(n - 1)]
    f (t - 1)

main :: IO ()
main = do
    t <- readLn
    f t

f :: Int -> IO ()
f 0 = return ()
f t = do
    n <- readLn
    putStrLn . unwords . map show $ n : [1..(n - 1)]
    f (t - 1)

main :: IO ()
main = do
    t <- readLn
    f t

f :: Int -> IO ()
f 0 = return ()
f t = do
    n <- readLn :: IO Int
    putStrLn . unwords . map show $ (n : [1..(n - 1)])
    f (t - 1)

main :: IO ()
main = do
    t <- readLn :: IO Int
    f t

import Control.Monad
import Data.List

main = do
  testCases <- read <$> getLine
  replicateM testCases $ do
    permutationLength <- read <$> getLine :: IO Int
    putStrLn $ mconcat $ intersperse " " $ map show $ reverse [1 .. permutationLength]

import Control.Monad ( replicateM )

main :: IO ()
main = do
    t <- readLn
    putStrLn . unlines . map (\n -> unwords . map show $ n : [2..(n - 1)]) =<< replicateM t (readLn :: IO Int)


{-#LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Int
import Data.List
import qualified Data.IntMap.Strict as M
import Data.Tuple
import Data.Maybe(fromJust)
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Control.DeepSeq

data Node = Node !Int !Node !Node | Empty

getSum :: Node -> Int
getSum (Node s _ _) = s

build :: Int -> Int -> Node
build !l !r
    | l == r = Node 0 Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in Node 0 (build l m) (build (m + 1) r)

update :: Node -> Int -> Int -> Int -> Int -> Node
update !(Node !val !left !right) !l !r !pos !delta
    | l == r = Node (val + delta) Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in
            if pos <= m then
                Node (val + delta) (update left l m pos delta) right
            else
                Node (val + delta) left (update right (m + 1) r pos delta)

get :: Node -> Int -> Int -> Int -> Int -> Int
get !(Node !val !left !right) !tl !tr !l !r
    | l == tl && r == tr = val
    | otherwise =
        let m = (tl + tr) `div` 2
        in
            if l <= m then
                (get left tl m l (min r m)) + getSum right
            else
                get right (m + 1) tr (max (m + 1) l) r
solve :: [(Int, Int)] -> Int64

solve xs =
    let n = length xs
        step :: (Node, Int64) -> (Int, Int) -> (Node, Int64)
        step (!root, !res) (!pos, !size) =
            let add = ((fromIntegral size) :: Int64) *
                      (fromIntegral $ get root 0 (n - 1) pos (n - 1))
                root' = update root 0 (n - 1) pos size
            in
                (root', res + add)
    in
        snd $ foldl' step (build 0 (n - 1), 0::Int64) xs

makeSwaps :: [(Int, Int)] -> ([Int], [Int]) -> [(Int, Int)]
makeSwaps swaps !(vals, s) =
    let
        initVals = M.fromAscList $ zip vals vals
        step !vs (!a, !b) =
            let va = vs M.! a
                vb = vs M.! b
                vs' = M.insert a vb vs
            in
                M.insert b va vs'
        finalVals = M.assocs $ foldl' step initVals swaps
        compressed = finalVals `deepseq` M.fromAscList $ zip vals (zip [0..] s)
   in
        map (\(_, a) -> (let (f, s) = compressed M.! a in (f, s))) finalVals

getSizes :: [Int] -> ([Int], [Int])
getSizes [] = ([], [])
getSizes [x] = ([x], [1])
getSizes (x:y:xs)
    | x == y - 1 =
        let (!a, !b) = getSizes(y:xs)
        in (x:a, 1:b)
    | otherwise =
        let (!a, !b) = getSizes(y:xs)
        in (x:x + 1:a, 1:y - x - 1:b)

main = do
    input <- B.getContents
    let (line:lines) = B.lines input
    let n = lines `deepseq` (fst . fromJust $ B.readInt line)
    let swaps = map (\l -> let [x, y] = B.words l in (fst . fromJust $ B.readInt x, fst . fromJust $ B.readInt y)) lines
    let sizes = swaps `deepseq` getSizes (S.elems $ foldl' (\acc (a, b) -> S.insert a (S.insert b acc)) (S.empty::S.Set Int) swaps)
    let afterSwaps = sizes `deepseq` makeSwaps swaps sizes
    let size = afterSwaps `deepseq` length (fst sizes)
    let res = solve afterSwaps
    print res

{-#LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Int
import Data.List
import qualified Data.Map.Strict as M
import Data.Tuple
import Data.Maybe(fromJust)
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.Array.IO
import Data.Bits
import qualified Data.Sequence as Seq

updateAt :: IOUArray Int Int -> Int -> Int -> Int -> IO ()
updateAt f !n !at !delta
    | at >= n = return ()
    | otherwise = do
        cur <- readArray f at
        writeArray f at (delta + cur)
        updateAt f n (at .|. (at + 1)) delta

getAt :: IOUArray Int Int -> Int -> Int -> IO Int
getAt f !at !acc
    | at < 0 = return acc
    | otherwise = do
        cur <- readArray f at
        getAt f ((at .&. (at + 1)) - 1) (acc + cur)

solve :: [(Int, Int)] -> IOUArray Int Int -> Int -> IO Int64
solve [] _ _  = return 0
solve !((pos, size):xs) tree !n = do
    sum <- getAt tree pos 0
    let res = (fromIntegral sum) * (fromIntegral size)
    _ <- updateAt tree n pos size
    rest <- solve xs tree n
    return (rest + res)

makeSwaps :: [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
makeSwaps swaps sizes =
    let vals = map fst sizes
        s = map snd sizes
        initVals = M.fromAscList $ zip vals vals
        step !vs (!a, !b) =
            let va = vs M.! a
                vb = vs M.! b
                vs' = M.insert a vb vs
            in
                M.insert b va vs'
        finalVals = M.assocs $ foldl' step initVals swaps
        compressed = M.fromAscList $ zip vals (zip [0..] s)
   in
        map (\(_, a) -> (let (f, s) = compressed M.! a in (f, s))) finalVals

getSizes :: [Int] -> [(Int, Int)]
getSizes ![] = []
getSizes ![x] = [(x, 1)]
getSizes !(x:y:xs)
    | x == y = getSizes(y:xs)
    | x == y - 1 = (x, 1) : getSizes (y:xs)
    | otherwise = (x, 1) : (x + 1, y - x - 1) : getSizes (y:xs)

main = do
    input <- B.getContents
    let (line:lines) = B.lines input
    let n = fst . fromJust $ B.readInt line
    let swaps = map (\l -> let [x, y] = B.words l in (fst . fromJust $ B.readInt x, fst . fromJust $ B.readInt y)) lines
    let all = foldl' (\acc (a, b) -> a : b : acc) [] swaps
    let sizes = getSizes (S.elems (S.fromList all))
    let afterSwaps = makeSwaps swaps sizes
    let size = length sizes
    tree <- newArray (0, size - 1) 0 :: IO (IOUArray Int Int)
    res <- solve (reverse afterSwaps) tree size
    print res

-- This solution is purely functional.

{-#LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Int
import Data.List
import qualified Data.IntMap.Strict as M
import Data.Tuple
import Data.Maybe(fromJust)
import qualified Data.IntSet as S
import qualified Data.ByteString.Char8 as B
import Control.DeepSeq

data Node = Node !Int !Node !Node | Empty

getSum :: Node -> Int
getSum (Node s _ _) = s

build :: Int -> Int -> Node
build !l !r
    | l == r = Node 0 Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in Node 0 (build l m) (build (m + 1) r)

update :: Node -> Int -> Int -> Int -> Int -> Node
update !(Node !val !left !right) !l !r !pos !delta
    | l == r = Node (val + delta) Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in
            if pos <= m then
                Node (val + delta) (update left l m pos delta) right
            else
                Node (val + delta) left (update right (m + 1) r pos delta)

get :: Node -> Int -> Int -> Int -> Int -> Int
get !(Node !val !left !right) !tl !tr !l !r
    | l == tl && r == tr = val
    | otherwise =
        let m = (tl + tr) `div` 2
        in
            if l <= m then
                (get left tl m l (min r m)) + getSum right
            else
                get right (m + 1) tr (max (m + 1) l) r
solve :: [(Int, Int)] -> Int64

solve xs =
    let n = length xs
        step :: (Node, Int64) -> (Int, Int) -> (Node, Int64)
        step (!root, !res) (!pos, !size) =
            let add = ((fromIntegral size) :: Int64) *
                      (fromIntegral $ get root 0 (n - 1) pos (n - 1))
                root' = update root 0 (n - 1) pos size
            in
                (root', res + add)
    in
        snd $ foldl' step (build 0 (n - 1), 0::Int64) xs

makeSwaps :: [(Int, Int)] -> ([Int], [Int]) -> [(Int, Int)]
makeSwaps swaps !(vals, s) =
    let
        initVals = M.fromAscList $ zip vals vals
        step !vs (!a, !b) =
            let va = vs M.! a
                vb = vs M.! b
                vs' = M.insert a vb vs
            in
                M.insert b va vs'
        finalVals = M.assocs $ foldl' step initVals swaps
        compressed = finalVals `deepseq` M.fromAscList $ zip vals (zip [0..] s)
   in
        map (\(_, a) -> (let (f, s) = compressed M.! a in (f, s))) finalVals

getSizes :: [Int] -> ([Int], [Int])
getSizes [] = ([], [])
getSizes [x] = ([x], [1])
getSizes (x:y:xs)
    | x == y - 1 =
        let (!a, !b) = getSizes(y:xs)
        in (x:a, 1:b)
    | otherwise =
        let (!a, !b) = getSizes(y:xs)
        in (x:x + 1:a, 1:y - x - 1:b)

main = do
    input <- B.getContents
    let (line:lines) = B.lines input
    let n = lines `deepseq` (fst . fromJust $ B.readInt line)
    let swaps = map (\l -> let [x, y] = B.words l in (fst . fromJust $ B.readInt x, fst . fromJust $ B.readInt y)) lines
    let sizes = swaps `deepseq` getSizes (S.elems $ foldl' (\acc (a, b) -> S.insert a (S.insert b acc)) S.empty swaps)
    let afterSwaps = sizes `deepseq` makeSwaps swaps sizes
    let size = afterSwaps `deepseq` length (fst sizes)
    let res = solve afterSwaps
    print res

{-#LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Int
import Data.List
import qualified Data.IntMap.Strict as M
import Data.Tuple
import Data.Maybe(fromJust)
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.Array.IO
import Data.Bits
import qualified Data.Sequence as Seq

updateAt :: IOUArray Int Int -> Int -> Int -> Int -> IO ()
updateAt f !n !at !delta
    | at >= n = return ()
    | otherwise = do
        cur <- readArray f at
        writeArray f at (delta + cur)
        updateAt f n (at .|. (at + 1)) delta

getAt :: IOUArray Int Int -> Int -> Int -> IO Int
getAt f !at !acc
    | at < 0 = return acc
    | otherwise = do
        cur <- readArray f at
        getAt f ((at .&. (at + 1)) - 1) (acc + cur)

solve :: [(Int, Int)] -> IOUArray Int Int -> Int -> IO Int64
solve [] _ _  = return 0
solve !((pos, size):xs) tree !n = do
    sum <- getAt tree pos 0
    let res = (fromIntegral sum) * (fromIntegral size)
    _ <- updateAt tree n pos size
    rest <- solve xs tree n
    return (rest + res)

makeSwaps :: [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
makeSwaps swaps sizes =
    let vals = map fst sizes
        s = map snd sizes
        initVals = M.fromAscList $ zip vals vals
        step !vs (!a, !b) =
            let va = vs M.! a
                vb = vs M.! b
                vs' = M.insert a vb vs
            in
                M.insert b va vs'
        finalVals = M.assocs $ foldl' step initVals swaps
        compressed = M.fromAscList $ zip vals (zip [0..] s)
   in
        map (\(_, a) -> (let (f, s) = compressed M.! a in (f, s))) finalVals

getSizes :: [Int] -> [(Int, Int)]
getSizes ![] = []
getSizes ![x] = [(x, 1)]
getSizes !(x:y:xs)
    | x == y = getSizes(y:xs)
    | x == y - 1 = (x, 1) : getSizes (y:xs)
    | otherwise = (x, 1) : (x + 1, y - x - 1) : getSizes (y:xs)

main = do
    input <- B.getContents
    let (line:lines) = B.lines input
    let n = fst . fromJust $ B.readInt line
    let swaps = map (\l -> let [x, y] = B.words l in (fst . fromJust $ B.readInt x, fst . fromJust $ B.readInt y)) lines
    let all = foldl' (\acc (a, b) -> a : b : acc) [] swaps
    let sizes = getSizes (S.elems (S.fromList all))
    let afterSwaps = makeSwaps swaps sizes
    let size = length sizes
    tree <- newArray (0, size - 1) 0 :: IO (IOUArray Int Int)
    res <- solve (reverse afterSwaps) tree size
    print res

{-#LANGUAGE BangPatterns #-}

import Control.Monad
import Data.Int
import Data.List
import qualified Data.Map.Strict as M
import Data.Tuple
import Data.Maybe(fromJust)
import qualified Data.ByteString.Char8 as B

data Node = Node !Int !Node !Node | Empty

build :: Int -> Int -> Node
build !l !r
    | l == r = Node 0 Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in Node 0 (build l m) (build (m + 1) r)

update :: Node -> Int -> Int -> Int -> Int -> Node
update !(Node !val !left !right) !l !r !pos !delta
    | l == r = Node (val + delta) Empty Empty
    | otherwise =
        let m = (l + r) `div` 2
        in
            if pos <= m then
                Node (val + delta) (update left l m pos delta) right
            else
                Node (val + delta) left (update right (m + 1) r pos delta)

get :: Node -> Int -> Int -> Int -> Int -> Int
get !(Node !val !left !right) !tl !tr !l !r
    | l == tl && r == tr = val
    | otherwise =
        let m = (tl + tr) `div` 2
            sumL = if l <= m then get left tl m l (min r m) else 0
            sumR = if r > m then get right (m + 1) tr (max (m + 1) l) r else 0
        in
            sumL + sumR

solve :: [(Int, Int)] -> Int64
solve xs =
    let n = length xs
        step :: (Node, Int64) -> (Int, Int) -> (Node, Int64)
        step (!root, !res) (!pos, !size) =
            let add = ((fromIntegral size) :: Int64) *
                      (fromIntegral $ get root 0 (n - 1) pos (n - 1))
                root' = update root 0 (n - 1) pos size
            in
                (root', res + add)
    in
        snd $ foldl' step (build 0 (n - 1), 0::Int64) xs

makeSwaps :: [(Int, Int)] -> [(Int, Int)] -> [(Int, Int)]
makeSwaps swaps sizes =
    let vals = map fst sizes
        s = map snd sizes
        initVals = M.fromAscList $ zip vals vals
        step vs (a, b) =
            let va = vs M.! a
                vb = vs M.! b
                vs' = M.insert a vb vs
            in
                (M.insert $ b) va $ vs'
        finalVals = M.assocs $ foldl' step initVals swaps
        compressed = M.fromAscList $ zip vals (zip [0..] s)
   in
        map (\(_, a) -> (let (f, s) = compressed M.! a in (f, s))) finalVals

getSizes :: [Int] -> [(Int, Int)]
getSizes [] = []
getSizes [x] = [(x, 1)]
getSizes (x:y:xs)
    | x == y = getSizes(y:xs)
    | x == y - 1 = (x, 1) : getSizes (y:xs)
    | otherwise = (x, 1) : (x + 1, y - x - 1) : getSizes (y:xs)

readInt :: IO Int
readInt = head `liftM` readIntList

readIntList :: IO [Int]
readIntList = do
    line <- B.getLine
    let res = map (fst . fromJust . B.readInt) $ B.words line
    return res

readSwaps :: Int -> IO ([(Int, Int)], [Int])
readSwaps 0 = (return ([], [])) :: IO ([(Int, Int)], [Int])
readSwaps n = do
    [a, b] <- readIntList
    (swaps, all) <- readSwaps (n - 1)
    return ((a, b):swaps, a:b:all)

main = do
    n <- readInt
    (swaps, all) <- readSwaps n
    let sizes = getSizes (sort all)
    print $ length sizes
    let afterSwaps = makeSwaps swaps sizes
    print $ solve afterSwaps