solve :: String -> Int -> Int -> String solve s i j = f 0 s where si = s !! i sj = s !! j f _ [] = [] f l (r:rs) = r' : f (l + 1) rs where r' | l == i = sj | l == j = si | otherwise = r main = do s <- getLine [i,j] <- map read . words <$> getLine :: IO [Int] putStrLn $ solve s i j