Problem: One-Way Conveyors

You are working at a factory manufacturing many different products. Products have to be processed on a number of different machine tools. Machine shops with these machines are connected with conveyor lines to exchange unfinished products. Each unfinished product is transferred from a machine shop to another through one or more of these conveyors.

As the orders of the processes required are not the same for different types of products, the conveyor lines are currently operated in two-way. This may induce inefficiency as conveyors have to be completely emptied before switching their directions. Kaizen (efficiency improvements) may be found here!

Adding more conveyors is too costly. If all the required transfers are possible with currently installed conveyors operating in fixed directions, no additional costs are required. All the required transfers, from which machine shop to which, are listed at hand. You want to know whether all the required transfers can be enabled with all the conveyors operated in one-way, and if yes, directions of the conveyor lines enabling it.

Input

The input consists of a single test case of the following format.


$n$ $m$
$x_1$ $y_1$
.
.
.
$x_m$ $y_m$
$k$
$a_1$ $b_1$
.
.
.
$a_k$ $b_k$


The first line contains two integers $n$ ($2 \leq n \leq 10 000$) and $m$ ($1 \leq m \leq 100 000$), the number of machine shops and the number of conveyors, respectively. Machine shops are numbered $1$ through $n$. Each of the following $m$ lines contains two integers $x_i$ and $y_i$ ($1 \leq x_i < y_i \leq n$), meaning that the $i$-th conveyor connects machine shops $x_i$ and $y_i$. At most one conveyor is installed between any two machine shops. It is guaranteed that any two machine shops are connected through one or more conveyors. The next line contains an integer $k$ ($1 \leq k \leq 100 000$), which indicates the number of required transfers from a machine shop to another. Each of the following $k$ lines contains two integers $a_i$ and $b_i$ ($1 \leq a_i \leq n$, $1 \leq b_i \leq n$, $a_i \ne b_i$), meaning that transfer from the machine shop $a_i$ to the machine shop $b_i$ is required. Either $a_i \ne a_j$ or $b_i \ne b_j$ holds for $i \ne j$.

Output

Output “No” if it is impossible to enable all the required transfers when all the conveyors are operated in one-way. Otherwise, output “Yes” in a line first, followed by $m$ lines each of which describes the directions of the conveyors. All the required transfers should be possible with the conveyor lines operated in these directions. Each direction should be described as a pair of the machine shop numbers separated by a space, with the start shop number on the left and the end shop number on the right. The order of these $m$ lines do not matter as far as all the conveyors are specified without duplicates or omissions. If there are multiple feasible direction assignments, whichever is fine.

Sample Input 1


3 2
1 2
2 3
3
1 2
1 3
2 3


Sample Output 1


Yes
1 2
2 3


Sample Input 2


3 2
1 2
2 3
3
1 2
1 3
3 2


Sample Output 2


No


Sample Input 3


4 4
1 2
1 3
1 4
2 3
7
1 2
1 3
1 4
2 1
2 3
3 1
3 2


Sample Output 3


Yes
1 2
2 3
3 1
1 4






Example

Input

3 2
1 2
2 3
3
1 2
1 3
2 3


Output

Yes
1 2
2 3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 100;

vector<pair<int, int> > ret;
int num[N], low[N], TIME, nComp, id[N];
vector<int> e[N];
stack<int> st;

void dfs(int u, int p, int bef) {
    // cerr << "DFS " << u << ' ' << p << '\n';
    num[u] = low[u] = ++TIME;
    st.push(u);
    for (int v : e[u]) if (v != p) {
        if (num[v]) {
            if (num[v] > num[u]) continue;
            // cerr << "Reverse " << u << ' ' << v << '\n';
            ret.push_back({u, v});
            low[u] = min(low[u], num[v]);
            continue;
        }
        dfs(v, u, st.top());
        low[u] = min(low[u], low[v]);
    }
    if (low[u] == num[u]) {
        // SCC
        ++nComp;
        while (st.size() && st.top() != bef) {
            int v = st.top(); st.pop(); 
            id[v] = nComp;
        }
    } else {
        if (p != -1) ret.push_back({p, u});
    }
}

map< pair<int, int>, pair<int, int> > mp;
set<int> Set[N];
vector<int> newE[N];
void dfs2(int u, int p) {
    // cerr << "DFS " << u << '\n';
    for (int v : newE[u]) if (v != p) {
        dfs2(v, u);
        if (Set[u].size() < Set[v].size()) swap(Set[u], Set[v]);
        // cerr << "Set " << u << ": "; for (int x : Set[u]) cerr << x << ' '; cerr << endl;
        // cerr << "Set " << v << ": "; for (int x : Set[v]) cerr << x << ' '; cerr << endl;
        for (int x : Set[v]) {
            if (Set[u].count(-x)) {
                Set[u].erase(-x);
            } else Set[u].insert(x);
        }
        Set[v].clear();
    }
    if (Set[u].size() && *Set[u].begin() < 0 && *Set[u].rbegin() > 0) {
        cout << "No\n";
        exit(0);
    }
    if (Set[u].empty() || *Set[u].begin() > 0) {
        if (p != -1) ret.push_back(mp[{u, p}]);
    } else {
        if (p != -1) ret.push_back(mp[{p, u}]);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(1, -1, -1);
    int q;
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        int u, v;
        cin >> u >> v;
        if (id[u] == id[v]) continue;
        u = id[u], v = id[v];
        Set[u].insert(+i);
        Set[v].insert(-i);
    }
    for (int u = 1; u <= n; ++u) {
        // cerr << id[u] << " \n"[u == n];
        for (int v : e[u]) if (id[u] != id[v]) {
            newE[id[u]].push_back(id[v]);
            mp[{id[u], id[v]}] = {u, v};
        }
    }
    dfs2(1, -1);
    cout << "Yes\n";
    for (auto x : ret) cout << x.first << ' ' << x.second << '\n';
}