#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int f[N][20], p[N][20], n, ans = -2e9;
void dfs(string s) {
  if (s.size() == 10 && s != "0000000000") {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int num = 0;
      for (int j = 0; j < 10; j++)
        if (f[i][j] && s[j] == '1') num++;
      sum += p[i][num];
    }
    ans = max(ans, sum);
    return;
  }
  dfs(s + "0");
  dfs(s + "1");
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 10; j++) cin >> f[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 11; j++) cin >> p[i][j];
  dfs("");
  cout << ans << endl;
  return 0;
}
