#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector VI; typedef vector VVI; typedef vector VL; typedef vector VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back int p2[21]; int main() { p2[0]=1; rep(i,20){p2[i+1]=p2[i]*2;} int n,m,k;cin>>n>>m>>k; set A; int a; rep(i,k){cin>>a; A.insert(a-1);} int T[n][n]; rep(i,n)rep(j,n){cin>>T[i][j];} map rec; queue D; rep(i,n){rec[{p2[i],i,1}]=0; D.push({p2[i],i,1});} int ans=-1; while(D.size()>0){ VI z=D.front();D.pop(); //cout<