#include <bits/stdc++.h>
using namespace std;
inline signed wait() { return 0; }
inline void dout(const char *arg, ...) {}
template <typename T>
inline void SWAP(T &a, T &b) {
  T t = a;
  a = b;
  b = t;
}
inline void CSWAP(char *&a, char *&b) {
  char *t = a;
  a = b;
  b = t;
}
int _ret;
void read(int num, int *ar) {
  for (int i = 0; i < num; ++i) _ret = _ret = scanf("%d", &ar[i]);
}
void read(int num, long long int *ar) {
  for (int i = 0; i < num; ++i) _ret = _ret = scanf("%lld", &ar[i]);
}
void read(int num, double *ar) {
  for (int i = 0; i < num; ++i) _ret = _ret = scanf("%lf", &ar[i]);
}
void read(int num, int *ar1, int *ar2) {
  for (int i = 0; i < num; ++i) _ret = _ret = scanf("%d %d", &ar1[i], &ar2[i]);
}
void read(int num, long long int *ar1, long long int *ar2) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%lld %lld", &ar1[i], &ar2[i]);
}
void read(int num, double *ar1, double *ar2) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%lf %lf", &ar1[i], &ar2[i]);
}
void read(int num, int *ar1, int *ar2, int *ar3) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%d %d %d", &ar1[i], &ar2[i], &ar3[i]);
}
void read(int num, long long int *ar1, long long int *ar2, long long int *ar3) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%lld %lld %lld", &ar1[i], &ar2[i], &ar3[i]);
}
void read(int num, double *ar1, double *ar2, double *ar3) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%lf %lf %lf", &ar1[i], &ar2[i], &ar3[i]);
}
void read(int num, int *ar1, int *ar2, int *ar3, int *ar4) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%d %d %d %d", &ar1[i], &ar2[i], &ar3[i], &ar4[i]);
}
void read(int num, long long int *ar1, long long int *ar2, long long int *ar3,
          long long int *ar4) {
  for (int i = 0; i < num; ++i)
    _ret = _ret =
        scanf("%lld %lld %lld %lld", &ar1[i], &ar2[i], &ar3[i], &ar4[i]);
}
void read(int num, double *ar1, double *ar2, double *ar3, double *ar4) {
  for (int i = 0; i < num; ++i)
    _ret = _ret = scanf("%lf %lf %lf %lf", &ar1[i], &ar2[i], &ar3[i], &ar4[i]);
}
int ToBitArray(int num, int *ar) {
  int mask = 1;
  int i = 0;
  int cnt = 0;
  while (true) {
    ar[i] = num & mask;
    mask *= 2;
    if (ar[i]) ++cnt;
    if (mask > num) break;
    ++i;
  }
  return cnt;
}
void CombSort(int N, int *ar, int order_ascending) {
  if (N <= 1) return;
  int h = int(N / 1.3);
  int flag;
  int i;
  while (true) {
    flag = 0;
    for (i = 0; i + h < N; ++i) {
      if ((order_ascending && ar[i] > ar[i + h]) ||
          (!order_ascending && ar[i] < ar[i + h])) {
        swap<int>(ar[i], ar[i + h]);
        flag = 1;
      }
    }
    if (h == 1 && !flag) break;
    if (h == 9 || h == 10) h = 11;
    if (h > 1) h = int(h / 1.3);
  }
}
void CombSort_ll(int N, long long int *ar, int order_ascending) {
  if (N <= 1) return;
  int h = int(N / 1.3);
  int flag;
  int i;
  while (true) {
    flag = 0;
    for (i = 0; i + h < N; ++i) {
      if ((order_ascending && ar[i] > ar[i + h]) ||
          (!order_ascending && ar[i] < ar[i + h])) {
        swap<long long int>(ar[i], ar[i + h]);
        flag = 1;
      }
    }
    if (h == 1 && !flag) break;
    if (h == 9 || h == 10) h = 11;
    if (h > 1) h = int(h / 1.3);
  }
}
int EuclideanAlgorithm(int N, int *ar) {
  for (int n = 0; n < N - 1; ++n) {
    while (true) {
      if (ar[n] == 0 || ar[n + 1] == 0) {
        if (ar[n] < ar[n + 1]) ar[n] = ar[n + 1];
        ar[n + 1] = ar[n];
        break;
      }
      if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) {
        ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1];
        break;
      }
      if (ar[n] > ar[n + 1]) {
        ar[n] %= ar[n + 1];
      } else {
        ar[n + 1] %= ar[n];
      }
    }
  }
  return ar[N - 1];
}
int Euclid(int n, int *ar) { return EuclideanAlgorithm(n, ar); }
long long int EuclideanAlgorithm_lli(int N, long long int *ar) {
  for (int n = 0; n < N - 1; ++n) {
    while (true) {
      if (ar[n] == 0 || ar[n + 1] == 0) {
        if (ar[n] < ar[n + 1]) ar[n] = ar[n + 1];
        ar[n + 1] = ar[n];
        break;
      }
      if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) {
        ar[n + 1] = ar[n] < ar[n + 1] ? ar[n] : ar[n + 1];
        break;
      }
      if (ar[n] > ar[n + 1]) {
        ar[n] %= ar[n + 1];
      } else {
        ar[n + 1] %= ar[n];
      }
    }
  }
  return ar[N - 1];
}
long long int Euclid_lli(int n, long long int *ar) {
  return EuclideanAlgorithm_lli(n, ar);
}
int EuclideanAlgorithmPreserved(int N, int *ar) {
  int a, b;
  a = ar[0];
  for (int n = 0; n < N - 1; ++n) {
    b = ar[n + 1];
    while (true) {
      if (a == 0 || b == 0) {
        if (a < b) a = b;
        b = a;
        break;
      }
      if (a % b == 0 || b % a == 0) {
        b = a < b ? a : b;
        break;
      }
      if (a > b) {
        a %= b;
      } else {
        b %= a;
      }
    }
    a = b;
  }
  return a;
}
int Euclid2(int n, int *ar) { return EuclideanAlgorithmPreserved(n, ar); }
template <typename T>
void CombSort(int N, T *ar, int order_ascending) {
  if (N <= 1) return;
  int i, flag;
  int h = int(N / 1.3);
  while (true) {
    flag = 0;
    for (i = 0; i + h < N; ++i) {
      if (order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
          !order_ascending && ar[i].SortValue < ar[i + h].SortValue) {
        SWAP<T>(ar[i], ar[i + h]);
        flag = 1;
      }
    }
    if (h > 1) {
      h = int(h / 1.3);
      if (h == 9 || h == 10) h = 11;
    } else {
      if (!flag) break;
    }
  }
}
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
void Replace(char *c, int len, char before, char after) {
  for (int i = 0; i < len; ++i) {
    if (c[i] == before) c[i] = after;
  }
}
void Replace(char *c, char before, char after) {
  int len = strlen(c);
  Replace(c, len, before, after);
}
class csStack {
 public:
  csStack() { num = 0; }
  void alloc(int size) { param = new int[size]; }
  void sort(int order = 1) {
    if (num > 1) CombSort(num, param, order);
  }
  int num;
  int *param;
  void push(int p) { param[num++] = p; }
};
class csPosition {
 public:
  csPosition() { x = y = 0; }
  int x, y;
};
template <typename T>
class csPos {
 public:
  csPos() { x = y = 0; }
  T x, y;
};
char ch[200010], cbuf[128][1024];
int f[100][10];
int p[100][11];
signed main() {
  int N;
  _ret = _ret = scanf("%d", &N);
  for (int i = 0; i < N; ++i) read(10, f[i]);
  for (int i = 0; i < N; ++i) read(11, p[i]);
  int flag[10];
  int cnt[100];
  int total_open;
  long long int prof, mx_prof = -9223372036854775807;
  for (int i = 0; i < 1024; ++i) {
    total_open = 0;
    for (int j = 0; j < N; ++j) cnt[j] = 0;
    total_open = ToBitArray(i, flag);
    if (total_open == 0) continue;
    for (int j = 0; j < 10; ++j) {
      if (!flag[j]) continue;
      for (int k = 0; k < N; ++k) {
        if (f[k][j]) ++cnt[k];
      }
    }
    prof = 0;
    for (int i = 0; i < N; ++i) {
      prof += p[i][cnt[i]];
    }
    mx_prof = max(prof, mx_prof);
  }
  cout << mx_prof << endl;
  ;
  return wait();
}
