Problem: Monocarp plays a computer game called "Goblins and Gnomes". In this game, he manages a large underground city of gnomes and defends it from hordes of goblins.

The city consists of n halls and m one-directional tunnels connecting them. The structure of tunnels has the following property: if a goblin leaves any hall, he cannot return to that hall. 

The city will be attacked by k waves of goblins; during the i-th wave, i goblins attack the city. Monocarp's goal is to pass all k waves.

The i-th wave goes as follows: firstly, i goblins appear in some halls of the city and pillage them; at most one goblin appears in each hall. Then, goblins start moving along the tunnels, pillaging all the halls in their path. 

Goblins are very greedy and cunning, so they choose their paths so that no two goblins pass through the same hall. Among all possible attack plans, they choose a plan which allows them to pillage the maximum number of halls. After goblins are done pillaging, they leave the city.

If all halls are pillaged during the wave — Monocarp loses the game. Otherwise, the city is restored. If some hall is pillaged during a wave, goblins are still interested in pillaging it during the next waves.

Before each wave, Monocarp can spend some time preparing to it. Monocarp doesn't have any strict time limits on his preparations (he decides when to call each wave by himself), but the longer he prepares for a wave, the fewer points he gets for passing it. If Monocarp prepares for the i-th wave for t_i minutes, then he gets max(0, x_i - t_i ⋅ y_i) points for passing it (obviously, if he doesn't lose in the process).

While preparing for a wave, Monocarp can block tunnels. He can spend one minute to either block all tunnels leading from some hall or block all tunnels leading to some hall. If Monocarp blocks a tunnel while preparing for a wave, it stays blocked during the next waves as well.

Help Monocarp to defend against all k waves of goblins and get the maximum possible amount of points!

Input

The first line contains three integers n, m and k (2 ≤ n ≤ 50; 0 ≤ m ≤ (n(n - 1))/(2); 1 ≤ k ≤ n - 1) — the number of halls in the city, the number of tunnels and the number of goblin waves, correspondely.

Next m lines describe tunnels. The i-th line contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n; u_i ≠ v_i). It means that the tunnel goes from hall u_i to hall v_i. The structure of tunnels has the following property: if a goblin leaves any hall, he cannot return to that hall. There is at most one tunnel between each pair of halls.

Next k lines describe the scoring system. The i-th line contains two integers x_i and y_i (1 ≤ x_i ≤ 10^9; 1 ≤ y_i ≤ 10^9). If Monocarp prepares for the i-th wave for t_i minutes, then he gets max(0, x_i - t_i ⋅ y_i) points for passing it.

Output

Print the optimal Monocarp's strategy in the following format:

At first, print one integer a (k ≤ a ≤ 2n + k) — the number of actions Monocarp will perform. Next, print actions themselves in the order Monocarp performs them. The i-th action is described by a single integer b_i (-n ≤ b_i ≤ n) using the following format:

  * if b_i > 0 then Monocarp blocks all tunnels going out from the hall b_i; 
  * if b_i < 0 then Monocarp blocks all tunnels going into the hall |b_i|; 
  * if b_i = 0 then Monocarp calls the next goblin wave. 



You can't repeat the same block action b_i several times. Monocarp must survive all waves he calls (goblins shouldn't be able to pillage all halls). Monocarp should call exactly k waves and earn the maximum possible number of points in total.

If there are several optimal strategies — print any of them.

Examples

Input


5 4 4
1 2
2 3
4 3
5 3
100 1
200 5
10 10
100 1


Output


6
-2 -3 0 0 0 0 


Input


5 4 4
1 2
2 3
4 3
5 3
100 100
200 5
10 10
100 1


Output


6
0 -3 0 0 1 0


Input


5 10 1
1 2
1 3
1 4
1 5
5 2
5 3
5 4
4 2
4 3
2 3
100 100


Output


6
1 2 3 4 5 0

Note

In the first example, Monocarp, firstly, block all tunnels going in hall 2, secondly — all tunnels going in hall 3, and after that calls all waves. He spent two minutes to prepare to wave 1, so he gets 98 points for it. He didn't prepare after that, that's why he gets maximum scores for each of next waves (200, 10 and 100). In total, Monocarp earns 408 points.

In the second example, Monocarp calls for the first wave immediately and gets 100 points. Before the second wave he blocks all tunnels going in hall 3. He spent one minute preparing to the wave, so he gets 195 points. Monocarp didn't prepare for the third wave, so he gets 10 points by surviving it. Before the fourth wave he blocks all tunnels going out from hall 1. He spent one minute, so he gets 99 points for the fourth wave. In total, Monocarp earns 404 points.

In the third example, it doesn't matter how many minutes Monocarp will spend before the wave, since he won't get any points for it. That's why he decides to block all tunnels in the city, spending 5 minutes. He survived the wave though without getting any points.

Solution (in CPP):

Solution:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<tuple>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

struct Matching2 { // for bipartite graph
    static const int INF = 1<<29;
    const VI* G;
    VI matchM, matchW, dist;
    int ans;
    int SNK;

    bool dfs(int v) {
	if (v == SNK) return true;
	EACH (e, G[v]) if (dist[matchW[*e]] == dist[v]+1 && dfs(matchW[*e])) {
	    matchM[v] = *e;
	    matchW[*e] = v;
	    return true;
	}
	dist[v] = INF;
	return false;
    }

    Matching2(const VI G_[], int sizeM, int sizeW): G(G_), matchM(sizeM, -1), matchW(sizeW, sizeM), dist(sizeM+1), ans(0), SNK(sizeM) {
	VI qu; qu.reserve(sizeM+1);
	while (1) {
	    dist[SNK] = INF;
	    REP (i, sizeM) {
		if (matchM[i] == -1) { dist[i] = 0; qu.push_back(i); }
		else dist[i] = INF;
	    }
	    for (int i=0; i<(int)qu.size(); i++) {
		int v = qu[i];
		if (dist[v] < dist[SNK]) {
		    EACH (e, G[v]) if (dist[matchW[*e]] == INF) {
			dist[matchW[*e]] = dist[v] + 1;
			qu.push_back(matchW[*e]);
		    }
		}
	    }
	    if (dist[SNK] == INF) break;
	    qu.clear();
	    REP (i, sizeM) if (matchM[i] == -1 && dfs(i)) ans++;
	}
	REP (i, sizeW) if (matchW[i] == SNK) matchW[i] = -1;
    }
};

int N;
int M, K;
VI G[55];

vector<pair<int, int> > E;
bool in[55];
bool out[55];

LL R[55];

vector<pair<int, int> > B[55];

int calc() {
    REP (i, N) G[i].clear();

    EACH (e, E) {
	if (!out[e->first] && !in[e->second]) {
	    G[e->first].push_back(e->second);
	}
    }

    Matching2 X(G, N, N);

    return N - X.ans;
}

LL X[55], Y[55];

void MAIN() {
    scanf("%d%d%d", &N, &M, &K);
    REP (i, M) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	E.emplace_back(x, y);
    }

    for (int k=1; k<=K; k++) {
	scanf("%lld%lld", X+k, Y+k);
    }

    int cur = calc();

    for (int k=1; k<=K; k++) {
	while (cur <= k) {
	    pair<int, int> p(0, 0);

	    REP (i, N) {
		if (!in[i]) {
		    in[i] = true;
		    int tmp = calc();
		    if (cur < tmp) {
			p = make_pair(i, -1);
			cur = tmp;
			goto OUT;
		    }
		    in[i] = false;
		}
		if (!out[i]) {
		    out[i] = true;
		    int tmp = calc();
		    if (cur < tmp) {
			p = make_pair(i, 1);
			cur = tmp;
			goto OUT;
		    }
		    out[i] = false;
		}
	    }

OUT:
	    ;

	    B[k].push_back(p);
	}

	// eprintf("[%d] :", k);
	// EACH (e, B[k]) eprintf("%d %d, ", e->first, e->second);
	// eprintf("\n");
    }


    LL ans = -(1LL<<60);
    using Tuple = tuple<int, int, int>;
    vector<Tuple> best;

    // non zero;
    {
	vector<Tuple> guess;
	LL tmp = 0;
	int min_y = 1;
	for (int k=1; k<=K; k++) {
	    if (Y[min_y] > Y[k]) {
		min_y = k;
	    }
	    tmp += X[k];
	    tmp -= Y[min_y] * (LL)B[k].size();

	    EACH (e, B[k]) {
		guess.emplace_back(min_y, e->first, e->second);
	    }
	}

	if (ans < tmp) {
	    ans = tmp;
	    best = guess;
	}
    }

    // zero;
    for (int z=1; z<=K; z++) {
	vector<Tuple> guess;
	LL tmp = 0;
	int min_y = 1;
	memset(R, 0, sizeof R);

	for (int k=1; k<=K; k++) {
	    if (Y[min_y] > Y[k]) {
		min_y = k;
	    }

	    if (k < z) {
		R[min_y] += Y[min_y] * (LL)B[k].size();
		if (X[min_y] < R[min_y]) {
		    goto BAD;
		}
		tmp += X[k];
		tmp -= Y[min_y] * (LL)B[k].size();
	    } else if (z == k) {

	    } else {
		tmp += X[k];
	    }

	    EACH (e, B[k]) {
		if (k < z) {
		    guess.emplace_back(min_y, e->first, e->second);
		} else {
		    guess.emplace_back(z, e->first, e->second);
		}
	    }
	}

	if (ans < tmp) {
	    ans = tmp;
	    best = guess;
	}
BAD:
	;
    }


    eprintf("SCORE = %lld\n", ans);
    VI ANS;
    for (int k=1, idx=0; k<=K; k++) {
	while (idx < (int)best.size() && get<0>(best[idx]) <= k) {
	    int dummy, a, sgn;
	    tie(dummy, a, sgn) = best[idx];
	    ANS.push_back((a+1) * sgn);
	    idx++;
	}
	ANS.push_back(0);
    }
    printf("%d\n", (int)ANS.size());
    rprintf("%d", ANS.begin(), ANS.end());
}


int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}