import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

getTuple3 :: IO (Int, Int, Int)
getTuple3 = (\[a,b,c] -> (a, b, c)) . map read . words <$> getLine

f (a, b, c) (a', b', c') = (a' + max b c, b' + max c a, c' + max a b)

main = readLn >>= flip replicateM getTuple3 >>= print . (\(a,b,c) -> max a (max b c)) . foldl1 f