Attendance Assurance


Winson's Semester 2 has started, and he wants to make plans to ace his studies and win the Dean's "Most Locked In" award.

Semester 2 consists of NN days. On the ii-th day, 1≤i≤N1 \le i \le N, Winson will choose exactly one of his four units to attend a lecture on:

  • Unit A: gain aia_\text{i} knowledge points
  • Unit B: gain bib_\text{i} knowledge points
  • Unit C: gain cic_\text{i} knowledge points
  • Unit D: gain did_\text{i} knowledge points

Due to his dwindling attention span, Winson is unable to attend a lecture on the same unit two or more days in a row. That is, on the ii-th day, where 1<i≤N1 < i \le N, he cannot choose to attend the same lecture as he did on the i−1i-1-th day.

Find the maximum total knowledge points that Winson can gain over the semester.

Input

The first line contains an integer NN, the number of days in Semester 2. The following NN lines contain integers ai,bi,ci,dia_i, b_i, c_i, d_i, the number of knowledge points winson can gain by attending a unit's lecture on the iith day.

Output

Output the maximum total knowledge points that Winson can gain over the semester.

Constraints

  • 1≤n≤1051 \le n \le 10^5
  • 1≤ai,bi,ci,di≤1041 \le a_i, b_i, c_i, d_i \le 10^4

Example 1

Input 1
3
1 2 3 4
2 4 6 8
1 3 5 7
Output 1
17

If Winson chooses to go to Unit D's lecture on the first day, unit C's lecture on the second day, then unit D's lecture on the third day, he will obtain 4 + 6 + 7 = 17 knowledge points.

Example 2

Input 2
1
2102 2014 2004 2099
Output 2
2102

Example 3

Input 3
7
3 1 4 10
4 10 6 8
1 4 7 1
3 10 5 6
10 3 1 9
1 10 9 3
4 11 9 5
Output 3
67

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.