#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> f(n, vector<int>(10));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 10; ++j) cin >> f[i][j];
  vector<vector<int>> pair<long long, long long>(n, vector<int>(11));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 10; ++j) cin >> pair<long long, long long>[i][j];
  long long ans = 0;
  int flag = true;
  for (int bit = 1; bit <= (1 << 10); ++bit) {
    vector<int> s(n, 0);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 10; ++j) {
        if (bit & (1 << j)) {
          if (f[i][j]) s[i]++;
        }
      }
    }
    long long tmp = 0;
    for (int i = 0; i < n; ++i) tmp += pair<long long, long long>[i][s[i]];
    if (flag) {
      ans = tmp;
      flag = !flag;
    } else
      ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
