Alex defined good graphs:
Single vertex is a good graph.
If two good graphs have no common vertex then their union is a good graph.
If is a good graph then

(complement of ) is a good graph.
Try to solve the problem of finding maximal weighted clique in a good graph.
The first line contains the integer (1 \leq N \leq 500) - number of vertices in the good graph .
The next lines contain adjacency matrix of .
Each of last lines contains the integer w_i (1 \leq w_i \leq 1000) - the weight of -th vertex.
In the single line of the output file print the maximal weight of clique of graph .
Example 1