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 ll              long long 
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (ll)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll> 
#define pii             pair<int,int>
#define ld              long double

const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}


template<typename flow_t = long long>
struct Dinic {
    struct FlowEdge 
    {
        int v, u;
        flow_t cap, flow = 0;
        FlowEdge(int v, int u, flow_t cap) : v(v), u(u), cap(cap) {}
    };
    const flow_t flow_inf = numeric_limits<flow_t>::max()/2;
    vector<FlowEdge> edges;
    vector<vector<int>> adj;
    int n, m = 0;
    int s, t;
    // s -> source
    // t -> sink
    vector<int> level, ptr;
    queue<int> q;

    Dinic(int n, int s, int t) : n(n), s(s), t(t) 
    {
        adj.resize(n+1);
        level.resize(n+1);
        ptr.resize(n+1);
    }

    void add_edge(int v, int u, flow_t cap) 
    {
        edges.emplace_back(v, u, cap);
        edges.emplace_back(u, v, 0);
        adj[v].push_back(m);
        adj[u].push_back(m + 1);
        m += 2;
    }

    bool bfs() 
    {
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int id : adj[v]) {
                if (edges[id].cap - edges[id].flow < 1)
                    continue;
                if (level[edges[id].u] != -1)
                    continue;
                level[edges[id].u] = level[v] + 1;
                q.push(edges[id].u);
            }
        }
        return level[t] != -1;
    }

    flow_t dfs(int v, flow_t pushed) 
    {
        if (pushed == 0)
            return 0;
        if (v == t)
            return pushed;
        for (int& cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
            int id = adj[v][cid];
            int u = edges[id].u;
            if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
                continue;
            flow_t tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
            if (tr == 0)
                continue;
            edges[id].flow += tr;
            edges[id ^ 1].flow -= tr;
            return tr;
        }
        return 0;
    }

    flow_t flow() 
    {
        flow_t f = 0;
        while (true) {
            fill(level.begin(), level.end(), -1);
            level[s] = 0;
            q.push(s);
            if (!bfs())
                break;
            fill(ptr.begin(), ptr.end(), 0);
            while (flow_t pushed = dfs(s, flow_inf)) {
                f += pushed;
            }
        }
        return f;
    }
};
int _runtimeTerror_()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<set<int>> g(n+1),rg(n+1);
    for(int i=1;i<=m;++i)
    {
        int x,y;
        cin>>x>>y;
        g[x].insert(y);
        rg[y].insert(x);
    }
    vector<ll> x(k+1),y(k+1);
    for(int i=1;i<=k;++i)
        cin>>x[i]>>y[i];

    vector<ll> costs;
    vector<ll> move;
    int left = -1,right = -1;
    auto get = [&](vector<set<int>> &g,bool rev)
    {
        left = right = -1;
        Dinic<ll> flow(2*n+3,0,2*n+1);
        for(int i=1;i<=n;++i)
        {
            flow.add_edge(0,i,1);
            flow.add_edge(i+n,2*n+1,1);
            for(auto j:g[i])
            {
                if(!rev)
                    flow.add_edge(i,j+n,1);
                else
                    flow.add_edge(j,i+n,1);
            }
        }
        auto u = flow.flow();
        for(int i=1;i<=n;++i)
        {
            if(left != -1)
                break;
            for(auto j:flow.adj[i])
            {
                if(flow.edges[j].flow == 1)
                {
                    left = i;
                    right = flow.edges[j].u - n;
                    break;
                }
            }
        }
        return u;
    };
    vector<int> want(k+1,0);
    for(int i=1;i<=k;++i)
    {   
        int uu = i;
        if(n - get(g,false) > i)
            costs.push_back(0),move.push_back(0),want[i] = 0;
        else
        {
            bool can = false;
            for(int i=1;i<=n;++i)
            {
                if(g[i].empty())
                    continue;
                auto u = g;
                g[i].clear();
                if(n - get(g,false) > uu)
                {
                    costs.push_back(1);
                    move.push_back(i);
                    can = true;
                    for(auto j:u[i])
                        rg[j].erase(i);
                    break;
                }
                g[i] = u[i];
            }
            if(can)
            {
                want[i] = 1;
                continue;
            }
            for(int i=1;i<=n;++i)
            {
                if(rg[i].empty())
                    continue;
                auto u = rg;
                rg[i].clear();
                if(n - get(rg,true) > uu)
                {
                    costs.push_back(1);
                    move.push_back(-i);
                    can = true;
                    for(auto j:u[i])
                        g[j].erase(i);
                    break;
                }
                rg[i] = u[i];
            }
            if(can)
            {
                want[i] = 1;
                continue;
            }
            for(auto j:g[left])
                rg[j].erase(left);
            g[left].clear();
            for(auto j:rg[right])
                g[j].erase(right);
            rg[right].clear();
            costs.push_back(1);
            costs.push_back(1);
            move.push_back(left);
            move.push_back(-right);
            want[i] = 2;
        }
    }
    for(int i=1;i<=k;++i)
        want[i] += want[i-1];
    vector<vector<ll>> dp(k+1,vector<ll>(2*n+1,-INF));
    dp[0][0] = 0;
    for(int i=1;i<=k;++i)
    {
        for(int j=0;j<=sz(costs);++j)
        {
            if(j < want[i])
            {
                dp[i][j] = -INF;
                continue;
            }
            for(int k=0;k<=j;++k)
                amax(dp[i][j],dp[i-1][j-k] + max(0ll,x[i] - k * y[i]));
        }
    }
    ll ans = -INF;
    int last = -1;
    for(int i=0;i<=2*n;++i)
    {
        if(dp[k][i] > ans)
            amax(ans,dp[k][i]),last = i;
    }
    vector<int> val;
    val.push_back(0);
    for(int i=k-1;i>=0;--i)
    {
        for(int j=0;j<=2*n;++j)
        {
            if(j <= last && dp[i][j] + max(0ll,x[i+1] - (last-j)*y[i+1])== ans)
            {
                int k = last - j;
                ans -= max(0ll,x[i+1] - k * y[i+1]);
                while(k--)
                {
                    val.push_back(move.back());
                    move.pop_back();
                }
                last = j;
            }
        }
        if(i)
            val.push_back(0);
    }
    cout<<sz(val)<<"\n";
    reverse(all(val));
    for(auto j:val)
        cout<<j<<" ";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}