import Text.Printf (printf)

data Point = Point
    { x :: Double
    , y :: Double
    } deriving Show


koch :: Int -> Point -> Point -> IO ()
koch 0 p1 p2 = do
    return ()
koch n p1 p2 = do
    koch (n - 1) p1 s
    printf "%.8f %.8f\n" (x s) (y s)
    koch (n - 1) s u
    printf "%.8f %.8f\n" (x u) (y u)
    koch (n - 1) u t
    printf "%.8f %.8f\n" (x t) (y t)
    koch (n - 1) t p2
  where
    s = Point
            ((x p1 * 2 + x p2) / 3)
            ((y p1 * 2 + y p2) / 3)
    t = Point
            ((x p1 + x p2 * 2) / 3)
            ((y p1 + y p2 * 2) / 3)
    u = Point
            ((x t - x s) * cos (pi / 3) - (y t - y s) * sin (pi / 3) + x s)
            ((x t - x s) * sin (pi / 3) + (y t - y s) * cos (pi / 3) + y s)


main :: IO ()
main = do
    n <- readLn :: IO Int
    printf "%.8f %.8f\n" (x p1) (y p1)
    koch n p1 p2
    printf "%.8f %.8f\n" (x p2) (y p2)
  where
    p1 = Point 0 0
    p2 = Point 100 0
