#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ll = long long;
template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b){if(a < b) a = b;}


struct LowLink{
  int n, pos;
  vector<int> ord, low, par, blg, num;
  vector<vector<int> > G, C, T;
  vector<vector<pair<int, int> > > E;
  vector<int> ap;
  vector<pair<int, int> > bs, cand;
  LowLink(int n) : n(n), pos(0), ord(n, -1), low(n),
                   par(n,-1),blg(n, -1),num(n, 1), G(n){}
  void add_edge(int u, int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  bool is_bridge(int u, int v){
    if(ord[u] > ord[v]) swap(u, v);
    return ord[u] < low[v];
  }

  void dfs(int v){
    ord[v] = low[v] = pos++;
    for(int u:G[v]){
      if(u == par[v]) continue;
      if(ord[u] < ord[v])
        cand.emplace_back(min(u, v), max(u, v));
      if(~ord[u]){
        low[v] = min(low[v], ord[u]);
        continue;
      }
      par[u] = v;
      dfs(u);
      num[v] += num[u];
      low[v] = min(low[v], low[u]);
      if(is_bridge(u, v)) bs.emplace_back(u, v);
      if(low[u] >= ord[v]){
        E.emplace_back();
        while(1){
          auto e=cand.back();
          cand.pop_back();
          E.back().emplace_back(e);
          if(make_pair(min(u, v), max(u, v)) == e) break;
        }
      }
    }
  }

  void fill_component(int v){
    C[blg[v]].emplace_back(v);
    for(int u:G[v]){
      if(~blg[u] || is_bridge(u, v)) continue;
      blg[u] = blg[v];
      fill_component(u);
    }
  }

  void add_component(int v, int &k){
    if(~blg[v]) return;
    blg[v] = k++;
    C.emplace_back();
    fill_component(v);
  }

  int build(){
    for(int i=0;i<n;i++)
      if(ord[i] < 0) dfs(i);

    vector<int> cnt(n, 0);
    for(int i=0;i<n;i++){
      int p = par[i];
      if(p < 0) continue;
      if(par[p] < 0) cnt[p]++;
      else if(ord[p] <= low[i]) ap.emplace_back(p);
    }

    for(int i=0;i<n;i++)
      if(cnt[i] > 1) ap.emplace_back(i);
    sort(ap.begin(), ap.end());
    ap.erase(unique(ap.begin(), ap.end()) , ap.end());
    int k = 0;
    for(int i=0;i<n;i++) add_component(i, k);
    T.assign(k, vector<int>());
    for(auto e:bs){
      int u = blg[e.first], v = blg[e.second];
      T[u].emplace_back(v);
      T[v].emplace_back(u);
    }
    return k;
  }
};


struct LowestCommonAncestor{
  int n, h;
  vector<vector<int> > G, par;
  vector<int> dep;
  LowestCommonAncestor(){}
  LowestCommonAncestor(int n):n(n), G(n), dep(n){
    h = 1;
    while((1<<h) <= n) h++;
    par.assign(h, vector<int>(n, -1));
  }

  void add_edge(int u, int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  void dfs(int v,int p,int d){
    par[0][v] = p;
    dep[v] = d;
    for(int u:G[v])
      if(u != p) dfs(u, v, d+1);
  }

  void build(int r = 0){
    dfs(r, -1, 0);
    for(int k=0;k+1<h;k++)
      for(int v=0;v<n;v++)
        if(~par[k][v])
          par[k+1][v] = par[k][par[k][v]];
  }

  int lca(int u, int v){
    if(dep[u] > dep[v]) swap(u, v);
    for(int k=0;k<h;k++)
      if((dep[v] - dep[u]) >>k& 1)
        v = par[k][v];
    if(u == v) return u;
    for(int k=h-1;k>=0;k--)
      if(par[k][u] !=par[k][v])
        u = par[k][u], v = par[k][v];
    return par[0][u];
  }
  int distance(int u, int v){
    return dep[u] + dep[v] - dep[lca(u, v)] * 2;
  }
};


vector< vector<int> > T;
vector<int> up,dw;

// from -> to
using P = pair<int, int>;
set<P> sp,cmp_sp;

int cntU,cntD;
void dfs(int v,int p){
  for(int u:T[v]){
    if(u==p) continue;
    int preU=cntU,preD=cntD;
    dfs(u,v);
    if(cntU>preU&&cntD>preD){
      cout<<"No"<<endl;
      exit(0);
    }
    if(cntU>preU) cmp_sp.emplace(u,v);
    else cmp_sp.emplace(v,u);
  }
  cntU+=up[v];
  cntD+=dw[v];
}

vector< set<int> > S;

void add_edge(int p,int q){
  sp.emplace(p,q);
  S[p].erase(q);
  S[q].erase(p);
};

vector<int> used;
void dfs2(int v){
  used[v]=1;
  while(!S[v].empty()){
    int u=*S[v].begin();
    add_edge(v,u);
    if(used[u]) continue;
    dfs2(u);
  }
}

signed solve(){
  int n,m;
  cin>>n>>m;
  LowLink G(n);
  vector<int> xs,ys;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y);
    xs.emplace_back(x);
    ys.emplace_back(y);
  }
  int sz=G.build();

  LowestCommonAncestor H(sz);
  for(int v=0;v<sz;v++)
    for(int u:G.T[v])
      if(u<v) H.add_edge(u,v);

  H.build();

  int q;
  cin>>q;

  up.assign(sz,0);
  dw.assign(sz,0);

  vector< vector<int> > C(n);
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    C[a].emplace_back(b);
    a=G.blg[a];
    b=G.blg[b];
    int c=H.lca(a,b);
    up[a]++;
    up[c]--;
    dw[b]++;
    dw[c]--;
  }

  cntU=cntD=0;
  T=H.G;
  dfs(0,-1);

  S.resize(n);
  for(int i=0;i<m;i++){
    int x=xs[i],y=ys[i];
    if(G.blg[x]!=G.blg[y]){
      if(cmp_sp.count(P(G.blg[x],G.blg[y])))
        sp.emplace(x,y);
      else
        sp.emplace(y,x);
      continue;
    }
    S[x].emplace(y);
    S[y].emplace(x);
  }

  used.assign(n,0);
  for(int i=0;i<n;i++){
    if(used[i]) continue;
    dfs2(i);
  }

  // not used (sonnamonon nai);
  for(int i=0;i<m;i++){
    int x=xs[i],y=ys[i];
    assert(sp.count(P(x,y))^sp.count(P(y,x)));
  }

  if(0){
    vector< vector<int> > U(n);
    for(auto p:sp)
      U[p.first].emplace_back(p.second);

    for(int x=0;x<n;x++){
      vector<int> used(n,0);
      queue<int> que;
      used[x]=1;
      que.emplace(x);
      while(!que.empty()){
        int v=que.front();que.pop();
        for(int u:U[v]){
          if(used[u]) continue;
          used[u]=1;
          que.emplace(u);
        }
      }

      for(int y=0;y<n;y++)
        if(G.blg[x]==G.blg[y])
          assert(used[y]);

      for(int y:C[x]) assert(used[y]);
    }
  }

  assert((int)sp.size()==m);
  cout<<"Yes"<<endl;
  for(auto p:sp)
    cout<<p.first+1<<" "<<p.second+1<<"\n";
  cout<<flush;

  return 0;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  solve();
  return 0;
}



Measured memory_bytes: 16220