#include <iostream>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <memory>
#include <iterator>
#include <stdexcept>
#include <utility>
#include <string>
#include <sstream>
#include <cmath>
#include <queue>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;

#define testcases int testcases;\
cin >> testcases;\
for (int testcase = 0; testcase < testcases; testcase++)

#define input(...) long __VA_ARGS__;\
inputhelper(__VA_ARGS__);

#define gerzytet ios_base::sync_with_stdio(false);\
cin.tie(0), cout.tie(0);\
int N;

/*
#define listinput(var, type) cin >> N;\
vector<type> var = listinputhelper<type>(N);
*/

const int MAX_INT = numeric_limits<int>().max();
const int MIN_INT = numeric_limits<int>().min();
const ll MAX_LL = numeric_limits<ll>().max();
const ll MIN_LL = numeric_limits<ll>().min();


template<typename T>
string convert(T t) {
    ostringstream out;
    out << t;
    return out.str();
}

string convert(string s) {
    return '"' + s + '"';
}

string convert(const char* s) {
    string out("\"");
    return out + s + "\"";
}

template<typename T, typename V>
string convert(pair<T, V> p) {
    return "(" + convert(p.first) + ' ' + convert(p.second) + ")";
}

template<class Iterator>
string convert(Iterator start, Iterator end) {
    string out = "";
    out += '{';
    for (auto s = start; s != end; s++) {
        out += convert(*s) + ' ';
    }
    out += '}';
    return out;
}
template<typename T> string convert(vector<T> container) { return convert(container.begin(), container.end()); }
template<typename T> string convert(set<T> container) { return convert(container.begin(), container.end()); }
template<typename T, typename V> string convert(map<T, V> container) { return convert(container.begin(), container.end()); }
template<typename T> string convert(unordered_set<T> container) { return convert(container.begin(), container.end()); }
template<typename T, typename V> string convert(unordered_map<T, V> container) { return convert(container.begin(), container.end()); }

template<typename... Args>
void debug(int id, Args... args) {
    cout << '(' << id << "):";
    ostream* rubbish[] = { &(cout << ' ' << convert(args))... };
    cout << '\n';
}

template<typename T = int>
vector<T> listinput(int length) {
    vector<T> out(length);
    for (int i = 0; i < length; i++) {
        cin >> out[i];
    }
    return out;
}

template<typename T = int>
vector<T> listinput() {
    int length;
    cin >> length;
    return listinput<T>(length);
}


template<typename T>
void inputhelper(T& t) {
    cin >> t;
}

template<typename... Args, typename T>
void inputhelper(T& t, Args&...args) {
    cin >> t;
    inputhelper(args...);
}

template<typename T = int>
vector<vector<T>> gridinput(int rows, int cols) {
    vector<vector<T>> out(rows, vector<T>(cols));
    for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
            cin >> out[r][c];
        }
    }
    return out;
}

int main() {
    gerzytet;

    input(n);
    vector<vector<int>> pts(n, vector<int>(3));
    vector<vector<int>> dp(n, vector<int>(3, 0));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> pts[i][j];
        }
    }

    for (int i = 0; i < 3; i++) {
        dp[0][i] = pts[0][i];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) {
                    continue;
                }
                dp[i][j] = max(dp[i][j], dp[i-1][k]+pts[i][j]);
            }
        }
    }

    int best = MIN_INT;
    for (int i = 0; i < 3; i++) {
        best = max(best, dp[n-1][i]);
    }
    cout << best << '\n';
}

Measured memory_bytes: 14260