type Acc = (Int,[Int],[Int])
main :: IO ()
main = do
    n:p <- input <$> getContents
    let (addr,a,b) = answer n p
    putStrLn $ showans a
    putStrLn $ showans b

input :: String -> [Int]
input  = fmap read . words

answer :: Int -> [Int] -> Acc
answer n = foldl foldfunc (initacc n) 

foldfunc :: Acc -> Int -> Acc
foldfunc (addr,a,b) p = (addr+1, addtail addr p a, addhead addr p b)

initacc :: Int -> Acc
initacc n = (1, [1..n], reverse [1..n])

addtail :: Int -> Int -> [Int] -> [Int]
addtail addr p = zipWith (\i a -> if i >= p then a + addr else a) [1..]
addhead :: Int -> Int -> [Int] -> [Int]
addhead addr p = zipWith (\i a -> if i <= p then a + addr else a) [1..]

showans :: [Int] -> String
showans [] = ""
showans (x:xs) = (show x) ++ " " ++ (showans xs)
