-- Math Functions - Distance II

import Control.Monad
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  _  <- getLine
  [xs, ys] <- map (map read . words) <$> replicateM 2 getLine
  mapM_ (putStrLn . show . distance xs ys) [1, 2, 3, -1]

distance :: [Double] -> [Double] -> Double -> Double
distance xs ys (-1) = maximum . map abs $ zipWith (-) xs ys
distance xs ys p    = (** (1 / p)) . sum . map ((** p) . abs) $ zipWith (-) xs ys

