#include <bits/stdc++.h>
using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}

// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

// std::vector Declaration and Initialization
template<typename T>
vector<T> make_vector(size_t a, T x) { return vector<T>(a, x); }
template<typename T, typename U, typename... Ts>
auto make_vector(size_t a, U b, Ts... ts) {
    return vector<decltype(make_vector<T>(b,ts...))>(a, make_vector<T>(b, ts...));
}

// std::vector Input
template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto &e : v) is >> e;
    return is;
}

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::array Debug
template<typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl

// Weighted edge
template<typename T>
struct edge {
    int src, to;
    T cost;

    edge() {}
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

using LL = int64_t;

#define fs first
#define sc second

const int64_t MOD = 1e9+7;


struct LowLink {
    struct edge {
        int to, rev, used;
        edge(int to, int rev) :
            to(to), rev(rev), used(0) {}
    };
    vector<vector<edge>> g;
    const int sz;
    vector<int> ord, low, par;
    vector<int> used, _is_articulation;
    vector<int> articulations;
    vector<pair<int,int>> bridges;

    LowLink(int sz) :
        sz(sz), g(sz), ord(sz), low(sz), used(sz),
        par(sz), _is_articulation(sz) {}

    void add_edge(int u, int v) {
        g[u].emplace_back(v, (int)g[v].size());
        g[v].emplace_back(u, (int)g[u].size() - 1);
    }

    //LowLink(const vector<vector<int>>& g) :
    //    g(g), sz(g.size()), ord(sz), low(sz), used(sz),
    //    par(sz), _is_articulation(sz) {}

    void build() {
        int k = 0;
        for (int i = 0; i < sz; ++i) {
            if (!used[i]) dfs(i, -1, k);
        }
    }

    void dfs(int v, int p, int& k) {
        used[v] = 1;
        par[v] = p;
        low[v] = ord[v] = k++;
        int cnt = 0;
        for (auto& e : g[v]) {
            int to = e.to;
            if (!used[to]) {
                e.used = 1;
                ++cnt;
                dfs(to, v, k);
                low[v] = min(low[v], low[to]);
                _is_articulation[v] |= ord[v] <= low[to];
                if (ord[v] < low[to]) bridges.emplace_back(to, v);
            } else if (!g[to][e.rev].used) {
                low[v] = min(low[v], ord[to]);
            }
        }
        if (p == -1) _is_articulation[v] = cnt > 1;
        if (_is_articulation[v]) articulations.push_back(v);
    }

    bool is_articulation(int v) const { return _is_articulation[v]; }
    bool is_bridge(int u, int v) const {
        if (u != par[v] and v != par[u]) return false;
        if (u == par[v]) swap(u, v);
        return ord[v] < low[u];
    }
};

struct TwoEdgeConnectedComponents {
    //const vector<vector<int>> g;
    //const int sz;
    vector<vector<int>> t;
    vector<int> comp;
    LowLink lowlink;

    //TwoEdgeConnectedComponents(const vector<vector<int>>& g) :
    //    g(g), sz(g.size()), comp(sz, -1), lowlink(g) {}

    TwoEdgeConnectedComponents(int sz) :
        comp(sz, -1), lowlink(sz) {}

    void add_edge(int u, int v) { lowlink.add_edge(u, v); }

    void dfs(int v, int p, int& k) {
        if (p == -1 or lowlink.is_bridge(v, p)) comp[v] = k++;
        else comp[v] = comp[p];
        for (const LowLink::edge& e : lowlink.g[v]) {
            if (comp[e.to] == -1) dfs(e.to, v, k);
        }
    }

    void build() {
        lowlink.build();
        int k = 0;
        for (int i = 0; i < comp.size(); ++i) {
            if (comp[i] == -1) dfs(i, -1, k);
        }
        t.resize(k);
        for (const auto& tp : lowlink.bridges) {
            int u = comp[tp.first], v = comp[tp.second];
            t[u].push_back(v);
            t[v].push_back(u);
        }
    }
};


template<typename M, typename OM = M>
struct LazySegmentTree {
    int sz;
    vector<M> data;
    vector<OM> lazy;
    const M e;
    const OM oe;
    const function<M(M,M)> f;
    const function<M(M,OM,int)> g;
    const function<OM(OM,OM)> h;
    // f: 二つの区間の要素をマージする関数
    // g: 要素と作用素をマージする二項演算. 第三引数は区間幅
    // h: 作用素をマージする関数
    // e: モノイドの単位元
    // oe: 作用素の単位元

    LazySegmentTree(
            int n, const M& e, const OM& oe,
            const function<M(M,M)>& f,
            const function<M(M,OM,int)>& g,
            const function<OM(OM,OM)>& h
            ) : e(e), oe(oe), f(f), g(g), h(h) {
        sz = 1;
        while (sz < n) sz <<= 1;
        data.assign(2*sz, e);
        lazy.assign(2*sz, oe);
    }

    void set(int i, const M &x) {
        data[i + sz] = x;
    }

    void build() {
        for(int i = sz-1; i > 0; --i) {
            data[i] = f(data[2*i], data[2*i+1]);
        }
    }

    void propagate(int k, int len) {
        if (lazy[k] == oe) return;
        if (k < sz) {
            lazy[2*k  ] = h(lazy[2*k  ], lazy[k]);
            lazy[2*k+1] = h(lazy[2*k+1], lazy[k]);
        }
        data[k] = g(data[k], lazy[k], len);
        lazy[k] = oe;
    }

    void _update(int a, int b, const OM &x, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) return;
        else if (a <= l && r <= b) {
            lazy[k] = h(lazy[k], x);
            propagate(k, r - l);
        } else {
            _update(a, b, x, 2*k,   l, (l+r)/2);
            _update(a, b, x, 2*k+1, (l+r)/2, r);
            data[k] = f(data[2*k], data[2*k+1]);
        }
    }

    void update(int a, int b, const OM &x) {
        // update [a, b) with x.
        _update(a, b, x, 1, 0, sz);
    }

    M _query(int a, int b, int k, int l, int r) {
        propagate(k, r - l);
        if (r <= a || b <= l) return e;
        else if (a <= l && r <= b) return data[k];
        else return f(
                _query(a, b, 2*k,   l, (l+r)/2),
                _query(a, b, 2*k+1, (l+r)/2, r));
    }

    M query(int a, int b) {
        // return f[a, b).
        return _query(a, b, 1, 0, sz);
    }
};


struct HLDecomposition {
    const vector<vector<int>>& G;
    vector<int> par, size, depth, head, vid;
    // par[v]: parent of v
    // size[v]: size of subtree[v]
    // depth[v]: depth of v. depth[root] = 0
    // head[v]: head of row containing v
    // vid[v]: index of v when all the rows are aligned.

    void dfs(int v, int p, int d) {
        par[v] = p; depth[v] = d; size[v] = 1;
        for (int u : G[v]) {
            if (u == p) continue;
            dfs(u, v, d+1);
            size[v] += size[u];
        }
    }
    void hld(int v, int h, int& k) {
        head[v] = h; vid[v] = k++;
        int ma = 0, id = -1;
        for (int u : G[v]) {
            if (u == par[v]) continue;
            if (chmax(ma, size[u])) id = u;
        }
        if (id == -1) return;
        hld(id, h, k);
        for (int u : G[v]) {
            if (u == id || u == par[v]) continue;
            hld(u, u, k);
        }
    }

    HLDecomposition(const vector<vector<int>>& g) :
        G(g), par(g.size()), size(g.size()), depth(g.size()),
        head(g.size()), vid(g.size()) {}

    void build(int root = 0) {
        dfs(root, -1, 0);
        int k = 0;
        hld(root, root, k);
    }

    int lca(int u, int v) {
        for (;; v = par[head[v]]) {
            if (depth[head[u]] > depth[head[v]]) swap(u, v);
            if (head[u] == head[v]) {
                if (depth[u] > depth[v]) swap(u, v);
                return u;
            }
        }
    }

    template<typename UpdateQuery>
        void update(int u, int v, const UpdateQuery& q, bool edge = false) {
            // q(a, b): update [a, b).
            for (;; v = par[head[v]]) {
                if (depth[head[u]] > depth[head[v]]) swap(u, v);
                if (head[u] == head[v]) {
                    if (vid[u] > vid[v]) swap(u, v);
                    q(vid[u] + edge, vid[v] + 1);
                    break;
                } else {
                    q(vid[head[v]], vid[v] + 1);
                }
            }
        }

    template<typename Query, typename MergeFunc, typename T>
        T query(int u, int v, const Query& q, const MergeFunc& f, const T& ident, bool edge = false) {
            // q(a, b): return f[a, b).
            // f: 二つの区間の要素をマージする関数
            // ident: モノイドの単位元
            T ret = ident;
            for (;; v = par[head[v]]) {
                if (depth[head[u]] > depth[head[v]]) swap(u, v);
                if (head[u] == head[v]) {
                    if (vid[u] > vid[v]) swap(u, v);
                    return f(ret, q(vid[u] + edge, vid[v] + 1));
                } else {
                    ret = f(ret, q(vid[head[v]], vid[v] + 1));
                }
            }
        }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    TwoEdgeConnectedComponents G(n);
    for (int i = 0; i < m; ++i) {
        int s, t; cin >> s >> t; --s, --t;
        G.add_edge(s, t);
    }


    G.build();
    //DUMP(G.lowlink.ord);
    //DUMP(G.lowlink.low);
    //DUMP(G.comp);
    //DUMP(G.t);

    HLDecomposition hld(G.t);
    hld.build();

    LazySegmentTree<int> up(G.t.size(), 0, 0,
            [](int a,int b){ return a | b; },
            [](int a,int b,int w){ return a | b; },
            [](int a,int b){ return a | b; });
    LazySegmentTree<int> down(G.t.size(), 0, 0,
            [](int a,int b){ return a | b; },
            [](int a,int b,int w){ return a | b; },
            [](int a,int b){ return a | b; });

    int k; cin >> k;
    for (int i = 0; i < k; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        a = G.comp[a], b = G.comp[b];

        int lca = hld.lca(a, b);

        hld.update(lca, a, [&](int l,int r){ up.update(l, r, 1); }, true);
        hld.update(lca, b, [&](int l,int r){ down.update(l, r, 1); }, true);

        //cout << "  up: ";
        //for (int i = 0; i < G.t.size(); ++i) {
        //    cout << up.query(i,i+1) << " ";
        //}
        //cout << endl;
        //cout << "down: ";
        //for (int i = 0; i < G.t.size(); ++i) {
        //    cout << down.query(i,i+1) << " ";
        //}
        //cout << endl;
    }

    for (int i = 0; i < G.t.size(); ++i) {
        if (up.query(i,i+1) and down.query(i,i+1)) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    map<pair<int,int>, int> dir;

    for (const auto& tp : G.lowlink.bridges) {
        int u = tp.first, v = tp.second;
        int uu = hld.vid[G.comp[u]], vv = hld.vid[G.comp[v]];
        int lca = hld.lca(G.comp[u], G.comp[v]);
        if (lca == G.comp[u]) {
            // uid -> vid
            dir[make_pair(u,v)] = (down.query(vv,vv+1) ? 1 : -1);
        } else if (lca == G.comp[v]) {
            // vid -> uid
            dir[make_pair(v,u)] = (down.query(uu,uu+1) ? 1 : -1);
        } else {
            while(1) {}
        }
    }

    for (int i = 0; i < n; ++i) {
        for (const auto& e : G.lowlink.g[i]) {
            if (G.lowlink.is_bridge(i, e.to)) continue;
            if (i > e.to) continue;

            if (e.used) {
                dir[make_pair(i, e.to)] = 1;
            } else if (G.lowlink.g[e.to][e.rev].used) {
                dir[make_pair(i, e.to)] = -1;
            } else {
                dir[make_pair(i, e.to)] = (G.lowlink.ord[i] < G.lowlink.ord[e.to] ? -1 : 1);
            }
        }
    }

    for (const auto& tp : dir) {
        const auto& p = tp.first;
        int d = tp.second;
        int u = p.first, v = p.second;
        if (d == -1) swap(u,v);
        printf("%d %d\n", u+1, v+1);
    }

    return 0;
}



Measured memory_bytes: 12444