#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<int>> opendata(N, vector<int>(10));
  vector<vector<int>> valuedata(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> opendata.at(i).at(j);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++) {
      cin >> valuedata.at(i).at(j);
    }
  }
  vector<int> onoff{0, 1};
  int ans = -1000000, value, ccc = 0;
  vector<int> count(N);
  for (int a : onoff) {
    for (int b : onoff) {
      for (int c : onoff) {
        for (int d : onoff) {
          for (int e : onoff) {
            for (int f : onoff) {
              for (int g : onoff) {
                for (int h : onoff) {
                  for (int i : onoff) {
                    for (int j : onoff) {
                      if (ccc == 0) {
                        ccc++;
                        break;
                      }
                      value = 0;
                      vector<int> bin{a, b, c, d, e, f, g, h, i, j};
                      for (int k = 0; k < 10; k++) {
                        for (int l = 0; l < N; l++) {
                          if (k == 0) count.at(l) = 0;
                          count.at(l) += opendata.at(l).at(k) * bin.at(k);
                        }
                      }
                      for (int l = 0; l < N; l++) {
                        value += valuedata.at(l).at(count.at(l));
                      }
                      if (value > ans) ans = value;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
