import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { auto N = readln.chomp.to!int; auto X = iota(N).map!(_ => readln.split.map!(to!int)).array; auto A = new int[](N); foreach (i; 0..N) foreach (j; 0..N) if (X[i][j]) A[i] |= 1 << j; auto B = readln.split.map!(to!int).array; int ans = 1 << 29; foreach (i; 0..(1< (1 << j) & i).map!(j => B[j]).sum); } } ans.writeln; }