#include <bits/stdc++.h>

using namespace std;

#define For(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define sz(a) ((int)a.size())
#define Rep(i, n) for (int i = 0, _n = (n); i < _n; i++)

const int maxn = 100000 + 123;
int n, m, k;
vector<int> V[maxn];
const int maxm = 100000 + 123;

struct edge {
	int u, v; 
	void read() {
		cin >> u >> v;
	}
} e[maxm];
int color[maxn];
int other(int id, int x) {
	return x ^ e[id].u ^ e[id].v;
}

void readData() {
	cin >> n >> m ;
	
	For(i,1,m) {
		e[i].read();
		V[e[i].u].push_back(i);
		V[e[i].v].push_back(i);
	}
	cin >> k;
}

int low[maxn], num[maxn], timer = 0;
int ess[maxm];
int scc, belong[maxn];

void dfs(int u, int prevId) {
	low[u] = num[u] = ++timer;
	for (auto id: V[u]) if (prevId != id) {
		int v = other(id, u);
		
		if (num[v]) {
			low[u] = min(low[u], num[v]);
		} else {
			dfs(v, id);
			low[u] = min(low[u], low[v]);
		}
 	}
 	if (prevId != -1 && low[u] >= num[u]) {
		//cout << "cau: " <<  prevId << endl;
		ess[prevId] = 1;
	}
	//cout << "low num "  << u << " " << low[u] << " " << num[u] << endl; 
}

int ord[maxm]; /// = v => (u -> v)

vector<pair<int, int> > G[maxn]; ///tree
int papa[maxn];
void findComponent(int u) {
	belong[u] = scc;
	for (auto id: V[u]) if (!ess[id]) {
		int v = other(id, u);
		if (!belong[v]) {
			ord[id] = v;
			findComponent(v);
		} else {
			ord[id] = u;
		}
	}
}

void buildTree() {
	memset(low, 0, sizeof(low));
	memset(num, 0, sizeof(num));
	memset(ess, 0, sizeof(ess));
	timer = 0;
	scc = 0;
	
	For(u, 1, n) if (!num[u]) {
		dfs(u, -1);
	}
	
	memset(papa, 0, sizeof(papa));
	memset(belong, 0, sizeof(belong));
	memset(ord, 0, sizeof(ord));
	
	For(u, 1, n) if (!belong[u]) {
		++scc;
		findComponent(u);
	}
	
	For(i,1,m) {
		int u = e[i].u, v = e[i].v;
		if (belong[u] != belong[v]) {
			G[belong[u]].push_back({belong[v], i});
			G[belong[v]].push_back({belong[u], i});
		}
	}

}

int parentEdge[maxn];
int tin[maxn], tout[maxn];

int col[maxn][2];
int lv[maxn];
int a[maxn][2], pa[maxn][20];
void dfsInit(int u, int prev) {
	tin[u] = ++timer;
	for (auto nxt: G[u]) if (nxt.first != prev) {
		int v, id; tie(v, id) = nxt;
		parentEdge[v] = id;
		papa[v] = u;
		
		dfsInit(v, u);
	}
	tout[u] = timer;
}
void dfsCheck(int u, int prev) {
	for (auto nxt: G[u]) if (nxt.first != prev) {
		int v, id; tie(v, id) = nxt;
		lv[v] = lv[u] + 1; 
		col[v][0] = col[u][0];
		col[v][1] = col[u][1];
		
		col[v][color[v] - 1]++;
		dfsCheck(v, u);
	}
}
bool anc(int u, int v) {
	return tin[u] <= tin[v] && tout[u] <= tout[v];
}


struct DSU{
	int lab[maxn];
	
	void init() {
		lab[0] = 0;
		For(u,1,scc) lab[u] = u;
	}
	
	int f(int u) {
		return lab[u] == u ? u : lab[u] = f(lab[u]);
	}
	
	///connect u->v
	void join(int u, int v) {
		lab[u] = v;
	}
} dsu;

void fail() {
	cout << "No" << endl;
	exit(0);
}
///color = 1 thi la di xuong duoi, color = 2 thi la di len tren

void To(int p, int q) {
	if (p == q) return;
	///cout << "dang to" << p << " " << q << endl;
	///to tu p den LCA mau 2
	///to tu q den LCA mau 1
	
	int z = dsu.f(p);
	while (z && !anc(z, q)) {
		color[z] = 2;
		dsu.join(z, dsu.f(papa[z]));
		z = dsu.f(z);
	}
	z = dsu.f(q);
	while (z && !anc(z, p)) { 
		color[z] = 1;
		dsu.join(z, dsu.f(papa[z]));
		z = dsu.f(z);
	}
}

int LCA(int u, int v) {
	if (lv[u] < lv[v]) swap(u, v);
	for(int i = 0, diff = lv[u] - lv[v]; diff; i++, diff >>= 1)
		if (diff & 1) u = pa[u][i];
	if (u == v) return u;
	for(int i = 19; i >= 0; i--) 
		if (pa[u][i] != pa[v][i]) 
			u = pa[u][i], v = pa[v][i];
	return pa[u][0];
}

void tomau() {
	//For(u,1,n)  cout << belong[u] << endl;
	memset(papa,0,sizeof(papa));
	
	For(u,1,scc) if (!papa[u]) {
		dfsInit(u, -1);
	}
	
	memset(color, 0, sizeof(color));
	dsu.init();
	
	For(i,1,k) {
		int p, q; cin >> p >> q;
		p = belong[p], q = belong[q];
		a[i][0] = p, a[i][1] = q;
		To(p, q);
	}
	
	//cout << "." << color[2] << endl;
	For(u,1,scc) if (papa[u]) {
		int id = parentEdge[u];
		if (color[u] == 1) {
			///di tu papa[u] den u
			int x = e[id].u, y = e[id].v;
			//cout << "zz " << x << " " << y << endl;
			if (belong[x] == u) {
				ord[id] = x;
			} else {
				ord[id] = y;
			}
		} else {
			///di tu u den papa[u]
			///di tu papa[u] den u
			int x = e[id].u, y = e[id].v;
			if (belong[x] == papa[u]) {
				ord[id] = x;
			} else {
				ord[id] = y;
			}
		}
	}
	dfsCheck(1, -1);
	for(int i = 1; i <= scc; i++) pa[i][0] = papa[i];
	
	for(int j = 1; j < 20; j++)
		for(int i = 1; i <= scc; i++) pa[i][j] = pa[pa[i][j - 1]][j - 1];
	for(int i = 1; i <= k; i++) {
		int u = a[i][0], v = a[i][1];
		int z = LCA(u, v);
		
		if (col[u][1] - col[z][1] != lv[u] - lv[z])
			return fail();
		if (col[v][0] - col[z][0] != lv[v] - lv[z]) 
			return fail();
	}
}

void process() {
	buildTree();
	tomau();
	for (int i = 1; i <= m; i++) {
		if (!ord[i]) ord[i] = e[i].u;
	}
	
	cout << "Yes" << endl;
	For(i,1,m) {
		cout << other(i, ord[i]) << " " << ord[i] << "\n";
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
//	freopen("input.txt", "r", stdin);
	readData();
	process();
	
	return 0;
}



Measured memory_bytes: 13712