unittest
{
	assert( [ "3", "10 40 70", "20 50 80", "30 60 90" ].parse.expand.solve == 210 );
	assert( [ "1", "100 10 1" ].parse.expand.solve == 100 );
	assert( [ "7", "6 7 8", "8 8 3", "2 5 2", "7 8 6", "4 6 8", "2 3 4", "7 5 1" ].parse.expand.solve == 46 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abcs = new long[ 3 ][ n ];
	foreach( ref abc; abcs )
	{
		input.popFront;
		abc = input.front.split.to!( long[] );
	}
	return tuple( abcs );
}

auto solve( long[ 3 ][] abcs )
{
	auto dp = new long[ 3 ][ abcs.length ];
	
	dp[ 0 ][] = abcs[ 0 ][];
	for( auto h = 1L; h < abcs.length; h++ )
	{
		for( auto w = 0L; w < 3; w++ )
		{
			auto m = 0L;
			for( auto i = 0L; i < 3; i++ )
			{
				if( i != w ) m = max( m, dp[ h - 1 ][ i ] );		// 前日の違う活動のうち、一番幸福度が大きいものを選ぶ
			}
			dp[ h ][ w ] = m + abcs[ h ][ w ];
		}
	}
	
	return dp[ $ - 1 ].reduce!( max );
}
