import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec

getIntList = map read . words <$> getLine
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c
main = do
  
  [n,k] <- getIntList
  psl <- getIntList 
  csl <- getIntList 
  let ps = Vec.fromList (map (+(-1)) psl)
  let cs = Vec.fromList csl

  --ダブリングなら可能?
  let (_,_,ans) = Vec.unzip3(solve n k ps cs)
  putStrLn (show(maximum (Vec.toList ans)))

solve:: Int->Int->Vec.Vector Int ->Vec.Vector Int -> Vec.Vector(Int,Int,Int)
solve n k ps cs 
  | k==1 = Vec.zip3 ps cs cs
  | (k `mod` 2)==0 = sou n mae mae
  | otherwise = sou n (sou n mae mae) (Vec.zip3 ps cs cs)
  where
    mae = solve n (k `div` 2) ps cs

sou n ta tb = Vec.generate n (go ta tb)


  --一回のダブリング畳み込み  
go:: Vec.Vector  (Int,Int,Int) -> Vec.Vector  (Int,Int,Int) -> Int -> (Int,Int,Int)
go ta tb i =
  (fir (tb Vec.! p),(sec (ta Vec.!i))+(sec (tb Vec.!p)),max (trd (ta Vec.!i)) ((sec (ta Vec.!i))+(trd (tb Vec.!p))))
  where
    p= (fir (ta  Vec.! i))


--va :: (Vec.Unbox a, Num a) => Vec.Vector a