// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
using namespace std;
// mylittledoge
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int N,M,K;
cin >> N >> M >> K;
vector< vector<bool> > G(N,vector<bool>(M,true));
for(int i =0; i < K; i++) {
int a,b;
cin >> a >> b;
G[--a][--b] =false;}
// max. indep. set v grafe G
vector< vector<long long> > F(N+M+2,vector<long long>(N+M+2,0));
for(int i =0; i < N; i++) cin >> F[0][i+1];
for(int i =0; i < M; i++) cin >> F[N+1+i][N+1+M];
for(int i =1; i <= N; i++) for(int j =N+1; j <= N+M; j++)
if(G[i-1][j-N-1]) F[i][j] =OVER9000;
queue<int> q;
vector<long long> Fv(N+M+2,OVER9000);
vector<int> ako(N+M+2,-1);
while(true) {
Fv.clear(); ako.clear();
Fv.resize(N+M+2,OVER9000);
ako.resize(N+M+2,-1);
q.push(0);
while(!q.empty()) {
for(int i =0; i < N+M+2; i++) if(F[q.front()][i] > 0 && ako[i] == -1) {
Fv[i] =min(Fv[q.front()],F[q.front()][i]);
ako[i] =q.front();
q.push(i);}
q.pop();}
if(ako[N+M+1] == -1) break;
int akt =N+M+1;
long long f =Fv[N+M+1];
while(akt > 0) {
F[ako[akt]][akt] -=f;
F[akt][ako[akt]] +=f;
akt =ako[akt];}
}
vector<bool> vis(N+M+2,false);
q.push(0);
vis[0] =true;
while(!q.empty()) {
for(int j =0; j < N+M+2; j++) if(!vis[j] && F[q.front()][j] > 0) {
vis[j] =true;
q.push(j);}
q.pop();}
long long ans =0;
vector<int> V1,V2;
for(int i =1; i <= N; i++)
// je v ind. sete?
if(vis[i]) {
V1.push_back(i);
ans +=F[0][i]+F[i][0];}
for(int i =N+1; i <= N+M; i++)
if(!vis[i]) {
V2.push_back(i-N);
ans +=F[N+M+1][i]+F[i][N+M+1];}
cout << ans << "\n";
cout << V1.size() << "\n";
for(int i =0; i < V1.size(); i++) {
if(i > 0) cout << " ";
cout << V1[i];}
cout << "\n";
cout << V2.size() << "\n";
for(int i =0; i < V2.size(); i++) {
if(i > 0) cout << " ";
cout << V2[i];}
cout << "\n";
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxzZXQ+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8aW9tYW5pcD4KI2RlZmluZSBkaWJzIHJlc2VydmUKI2RlZmluZSBPVkVSOTAwMCAxMjM0NTY3ODkwMTIzNDU2Nzg5TEwKI2RlZmluZSBBTExfVEhFKENBS0UsTElFKSBmb3IoYXV0byBMSUUgPUNBS0UuYmVnaW4oKTsgTElFICE9IENBS0UuZW5kKCk7IExJRSsrKQojZGVmaW5lIHRpc2ljIDQ3CiNkZWZpbmUgc29jbG9zZSAxZS04CiNkZWZpbmUgY2hvY29sYXRlIHdpbgovLyBzbyBtdWNoIGNob2NvbGF0ZQojZGVmaW5lIHBhdGthbiA5CiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKI2RlZmluZSBhYn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