#include <iostream>
using namespace std;

int main() {
    // input
    int N;
    cin >> N;
    int F[N][10];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> F[i][j];
        }
    }
    int P[N][11];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            cin >> P[i][j];
        }
    }

    // solve
    int ans = 0, max = -1000;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j < 11; ++j) {
            max = max(max, P[i][j]);
        }
        ans += max;
        tmp = -1000;
    }

    // output
    cout << ans << endl;

    return 0;
}
