#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; vector a(k); rep(i, k) cin >> a[i]; vector t(n, vector(n)); rep(i, n) rep(j, n) cin >> t[i][j]; int ans = 1e9; vector p(n, -1); { int idx = 0; for (int i = n - m; i < n; ++i) p[i] = idx++; } do { vector v; rep(i, n) if (p[i] != -1) v.push_back(i); assert(v.size() == m); sort(v.begin(), v.end(), [&](int x, int y) { return p[x] < p[y]; }); int sum = 0; rep(i, m - 1) sum += t[v[i]][v[i + 1]]; for (int x : a) { ans = min(ans, sum + t[v.back()][x - 1]); } } while (next_permutation(p.begin(), p.end())); cout << ans << '\n'; return 0; }