#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} template ostream &operator<<(ostream &os,const pair&p){ os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector &a){ for(auto &i:a)is>>i; return is; } #define reps(i,a,n) for(int i=(a);i<(n);i++) #define rep(i,n) reps(i,0,n) #define all(x) x.begin(),x.end() ll myceil(ll a,ll b){return (a+b-1)/b;} int main(){ int n,s,t; cin>>n>>s>>t; ll sum=0; vectora(n,0); rep(i,s){ int b; cin>>b; b--; a[b]=1; } rep(i,t){ int b; cin>>b; b--; a[b]=2; } vector>c(n,vector(n)); mf_graphg(n+2); rep(i,n)rep(j,n){ cin>>c[i][j]; sum+=c[i][j]; g.add_edge(i,j,c[i][j]); } rep(i,n){ if(a[i]==1)g.add_edge(n,i,1e18); else if(a[i]==2)g.add_edge(i,n+1,1e18); } cout<