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:
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define per(i, n, a) for (int i = (n); i >= (int)(a); --i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
mt19937 rnd(time(0));

#ifdef LOCAL_DEBUG
#define Log(format, ...)                                                       \
  printf("\33[1;34m[%s,%d,%s] " format "\33[0m\n", __FILE__, __LINE__,         \
         __func__, ##__VA_ARGS__)

#define Log2(format, ...)                                                      \
  printf("\33[1;35m[%s,%d,%s] " format "\33[0m\n", __FILE__, __LINE__,         \
         __func__, ##__VA_ARGS__)

#define Assert(cond, ...)                                                      \
  do {                                                                         \
    if (!(cond)) {                                                             \
      fflush(stdout);                                                          \
      fprintf(stderr, "\33[1;31m");                                            \
      fprintf(stderr, __VA_ARGS__);                                            \
      fprintf(stderr, "\33[0m\n");                                             \
      assert(cond);                                                            \
    }                                                                          \
  } while (0)

#define panic(...) Assert(0, __VA_ARGS__)
#else
#define Log(format, ...)
#define Log2(format, ...)
#define Assert(cond, ...)
#define panic(...)
#endif

inline int in() {
  char ch = getchar();
  int f = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - '0', ch = getchar();
  return f * x;
}

namespace Flow {

using cap_t = int;
const cap_t cap_inf = 0x3f3f3f3f;
// using cap_t = long long;
// const cap_t cap_inf = 1ll << 60;

struct Edge {
  int to, rev;
  cap_t cap;
  Edge(int v, int r, cap_t c) {
    to = v;
    rev = r;
    cap = c;
  }
};

vector<int> cur, d;
vector<vector<Edge>> e;
int n, s, t;

void init(int size, int src, int dst) {
  s = src;
  t = dst;
  n = size;
  e.resize(n);
  d.resize(n);
  cur.resize(n);
}

void add_edge(int u, int v, cap_t c) {
  // Log("add_edge: (%d %d) %d", u, v, c);
  assert(u < n && v < n);
  e[u].emplace_back(v, e[v].size(), c);
  e[v].emplace_back(u, e[u].size() - 1, 0);
}

bool bfs() {
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    d[i] = 0x3f3f3f3f;
    cur[i] = 0;
  }
  q.push(s);
  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (const auto &v : e[u]) {
      if (v.cap && d[v.to] == 0x3f3f3f3f) {
        d[v.to] = d[u] + 1;
        q.push(v.to);
      }
    }
  }
  return d[t] != 0x3f3f3f3f;
}

cap_t dfs(int u, cap_t F) {
  if (u == t || !F)
    return F;
  cap_t res = 0;
  for (int &i = cur[u]; i < (int)e[u].size(); ++i) {
    auto &v = e[u][i];
    if (v.cap && d[v.to] == d[u] + 1) {
      cap_t w = dfs(v.to, min(v.cap, F - res));
      res += w;
      F -= w;
      v.cap -= w;
      e[v.to][v.rev].cap += w;
      if (F == 0)
        return res;
    }
  }
  return res;
}

cap_t Dinic() {
  cap_t flow = 0;
  while (bfs()) {
    flow += dfs(s, cap_inf);
  }
  return flow;
}

} // namespace Flow

const int N = 110;

void Initialization() {
  // Remember to modify [inf, N, mod, ...]
}

int n, m, k;
ll dp[N][N], x[N], y[N];
int pre[N][N];
int match[N], o[N];

void dfs(int u) {
  for (auto &ed : Flow::e[u]) {
    int v = ed.to;
    // Log("%d->%d", u, v);
    if (v >= n || o[v])
      continue;
    o[v] = 1;
    o[match[v]] = 1;
    dfs(match[v]);
  }
}

void solve(int CaseNum) {
  n = in(), m = in(), k = in();
  int s = 2 * n;
  int t = 2 * n + 1;
  Flow::init(2 * n + 2, s, t);
  rep(i, 1, m) {
    int u = in() - 1, v = in() - 1;
    Flow::add_edge(u, v + n, 1);
  }
  for (int i = 1; i <= k; ++i) {
    x[i] = in();
    y[i] = in();
  }
  rep(i, 0, n - 1) {
    Flow::add_edge(s, i, 1);
    Flow::add_edge(i + n, t, 1);
  }
  int ans = Flow::Dinic();
  memset(match, -1, sizeof(match));
  rep(i, 0, n - 1) {
    for (auto &ed : Flow::e[i]) {
      if (ed.cap == 0 && ed.to < 2 * n) {
        match[i] = ed.to;
        match[ed.to] = i;
      }
    }
  }
  // for (int i = 0; i < 2 * n; ++i) {
  //   cout << match[i] << " ";
  // }
  // cout << endl;

  rep(i, n, 2 * n - 1) {
    if (match[i] == -1)
      dfs(i);
  }

  // for (int i = 0; i < 2 * n; ++i)
  //   cout << o[i] << " ";
  // cout << endl;

  vector<int> del;
  for (int i = 0; i < n; ++i) {
    if (o[i] && match[i] != -1)
      del.push_back(i);
  }
  for (int i = n; i < 2 * n; ++i) {
    if (!o[i] && match[i] != -1)
      del.push_back(i);
  }

  // for (auto v : del)
  //   printf("%d ", v);
  // printf("\n");

  // dp[i][j]   in the i-th wave, max-matching = j, the maximum score
  for (int i = 0; i <= k; ++i)
    for (int j = 0; j <= n; ++j)
      dp[i][j] = -(1ll << 60), pre[i][j] = -1;
  dp[0][ans] = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 0; j < n - i; ++j) {
      for (int t = j; t <= n; ++t)
        if (dp[i - 1][t] >= 0) {
          if (dp[i - 1][t] + max(0ll, x[i] - (t - j) * y[i]) > dp[i][j]) {
            dp[i][j] = dp[i - 1][t] + max(0ll, x[i] - (t - j) * y[i]);
            pre[i][j] = t;
          }
        }
    }
  }
  // for (int i = 0; i <= k; ++i) {
  //   for (int j = 0; j < n - i; ++j) {
  //     if (dp[i][j] < 0)
  //       cout << "-1"
  //            << " ";
  //     else
  //       cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  int cur = n - k - 1, pos = k;
  for (int i = n - k - 1; i >= 0; i--) {
    if(dp[k][cur] < dp[k][i])
      cur = i;
  }
  Log("%lld", dp[pos][cur]);
  vector<int> act;
  while (pos > 0) {
    // Log("%d %d", pos, cur);
    act.push_back(0);
    int prev = pre[pos][cur];
    assert(prev != -1);
    // Log("%d %d", prev, cur);
    int delta = prev - cur;
    while (delta > 0) {
      assert(!del.empty());
      int x = del.back();
      del.pop_back();
      if (x >= n)
        act.push_back(-(x - n + 1));
      else
        act.push_back(x + 1);
      delta--;
    }
    cur = prev;
    pos--;
  }
  reverse(all(act));
  printf("%d\n", (int)act.size());
  for (auto v : act)
    printf("%d ", v);
  // printf("Case #%d: ", CaseNum);
}

int main() {
#ifdef LOCAL_DEBUG
  freopen("in.in", "r", stdin);
  // freopen("out.out", "w", stdout);
  clock_t _start_time = clock();
#endif
  int T = 1;
  // T = in();
  Initialization();
  rep(_, 1, T) solve(_);
#ifdef LOCAL_DEBUG
  Log2("Running Time: %.3lfs",
       ((double)clock() - _start_time) / CLOCKS_PER_SEC);
#endif
  return 0;
}