#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 500000 + 5;
const int INF = 0x3f3f3f3f;
const int P = 1000000007;
const double PI = acos(-1.0);
template <typename T>
inline T read(T &x) {
  x = 0;
  int _f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') _f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = _f ? -x : x;
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
int n, f[105][15], p[105][15], a;
bool vis[15];
void dfs(int c) {
  if (c == 10) {
    bool flag = false;
    for (int i = 1; i <= 10; i++) {
      if (vis[i] = true) {
        flag = true;
        break;
      }
    }
    if (!flag) return;
    int ans[105] = {0};
    for (int i = 1; i <= 10; i++) {
      if (vis[i]) {
        for (int j = 1; j <= n; j++) {
          if (f[j][i]) ans[j]++;
        }
      }
    }
    int x = 0;
    for (int i = 1; i <= n; i++) x += p[i][ans[i]];
    a = max(a, x);
    return;
  }
  vis[c + 1] = true;
  dfs(c + 1);
  vis[c + 1] = false;
  dfs(c + 1);
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 10; j++) {
      read(f[i][j]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 10; j++) {
      read(p[i][j]);
    }
  }
  a = -1000000000;
  dfs(0);
  cout << a << endl;
  return 0;
}
