import java.util.*
import kotlin.collections.ArrayList

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
    val edges = readEdges(m)
    val graph = makeGraph(n, edges)
    val k = readLine()!!.toInt()
    val orders = readOrder(k)
    val cycle = calCycle(graph)
    val map = mutableMapOf<Int, Int>()
    for (i in cycle.indices) if (cycle[i].first == cycle[i].second) {
        map[cycle[i].second] = map.size
    }
    val treeEdges = edges.filter{(u, v) -> cycle[u].second != cycle[v].second}.map{(u, v) -> map[cycle[u].second]!! to map[cycle[v].second]!!}
    val tree = Tree(makeGraph(map.size, treeEdges))
    val treeOrder = List(tree.size){Order(arrayListOf(), arrayListOf())}
    for ((u, v) in orders) if (cycle[u].second != cycle[v].second) {
        val a = map[cycle[u].second]!!
        val b = map[cycle[v].second]!!
        val lca = tree.lca(a, b)
        if (lca != a) treeOrder[lca].backward.add(a)
        if (lca != b) treeOrder[lca].forward.add(b)
    }
    val dfsPrev = calDFSPrev(graph)
    val height = makeConveyor(tree, treeOrder)
    if (height == null) {
        println("No")
    }else {
        println("Yes")
        for ((u, v) in edges ){
            if (cycle[u].second == cycle[v].second) {
                if (u == dfsPrev[v] || (dfsPrev[u] != v && cycle[u].first > cycle[v].first)) {
                    println("${u + 1} ${v + 1}")
                }else {
                    println("${v + 1} ${u + 1}")
                }
            }else {
                val a = map[cycle[u].second]!!
                val b = map[cycle[v].second]!!
                if (height[a] > height[b]) {
                    println("${u + 1} ${v + 1}")
                }else {
                    println("${v + 1} ${u + 1}")
                }
            }
        }
    }
}
fun readEdges(size: Int): List<Pair<Int, Int>> {
    return List(size){
        val (u, v) = readLine()!!.trim().split(' ').map(String::toInt)
        u - 1 to v - 1
    }
}
fun makeGraph(size: Int, edges: List<Pair<Int, Int>>): List<List<Int>> {
    return List(size){ArrayList<Int>()}.also{
        for ((u, v) in edges) {
            it[u].add(v)
            it[v].add(u)
        }
    }
}
fun readOrder(size: Int): Array<Pair<Int, Int>> {
    return Array(size){
        val (u, v) = readLine()!!.trim().split(' ').map(String::toInt)
        u - 1 to v - 1
    }
}


class UnionFind(val size: Int) {
    private val array: IntArray = IntArray(size){-1}
    fun find(a: Int): Int {
        return when {
            array[a] < 0 -> a
            else -> find(array[a]).also{array[a] = it}
        }
    }
    fun same(a: Int, b: Int): Boolean {
        return find(a) == find(b)
    }
    fun unite(a: Int, b: Int): Unit {
        val ar = find(a)
        val br = find(b)
        if (ar == br) return
        if (array[ar] < array[br]) {
            array[ar] += array[br]
            array[br] = ar
        }else {
            array[br] += array[ar]
            array[ar] = br
        }
    }
}
fun calCycle(nodes: List<List<Int>>): Array<Pair<Int, Int>> {
    val stack = Stack<Pair<Int, Int>>().also{it.add(0 to -1)}
    val result = Array(nodes.size){-1 to -1}
    var count = 0
    while (stack.isNotEmpty()) {
        val (top, prev) = stack.pop()
        if (top >= 0) {
            if (result[top].first != -1) continue
            result[top] = result[top].copy(first = count, second = count)
            ++count
            stack.push(-top - 1 to prev)
            for (next in nodes[top]) if (result[next].first == -1 && next != prev) {
                stack.push(next to top)
            }
        }else {
            var min = result[-top - 1].second
            for (next in nodes[-top - 1]) if (next != prev) {
                min = minOf(min, result[next].second)
            }
            result[-top - 1] = result[-top - 1].copy(second = min)
        }
    }
    val uft = UnionFind(nodes.size)
    for ((a, b) in result) uft.unite(a, b)
    for (i in result.indices) result[i] = result[i].copy(second = uft.find(result[i].second))
    return result
}
class Tree(private val mNode: List<List<Int>>) {
    private val mParent: List<List<Int>>
    private val mDepth: IntArray
    init {
        val parent = Array(mNode.size){ArrayList<Int>()}
        mDepth = IntArray(mNode.size){-1}.also{it[0] = 0}
        val stack = Stack<Int>().also{it.add(0)}
        while (stack.isNotEmpty()) {
            val top = stack.pop()
            for (next in mNode[top]) if (mDepth[next] == -1) {
                mDepth[next] = mDepth[top] + 1
                stack.push(next)
                parent[next].add(top)
                while (parent[next].size - 1 in parent[parent[next].last()].indices) {
                    parent[next].add(parent[parent[next].last()][parent[next].size - 1])
                }
            }
        }
        mParent = parent.map{it.toList()}
    }
    private fun moveUp(v: Int, step: Int): Int {
        return if (step == 0) v else (0 until 32).find{((1 shl it) and step) != 0}!!.let { moveUp(mParent[v][it], step - (1 shl it)) }
    }
    val size: Int
        get() = mNode.size
    fun lca(a: Int, b: Int): Int {
        if (mDepth[a] > mDepth[b]) return lca(moveUp(a, mDepth[a] - mDepth[b]), b)
        if (mDepth[a] < mDepth[b]) return lca(a, moveUp(b, mDepth[b] - mDepth[a]))
        if (a == b) return a
        var i = 0
        while (i + 1 in mParent[a].indices && mParent[a][i + 1] != mParent[b][i + 1]) ++i
        return lca(mParent[a][i], mParent[b][i])
    }
    fun neighbors(v: Int): List<Int> {
        return mNode[v]
    }
}
fun calETOrder(tree: Tree): Array<Pair<Int, Int>> {
    val stack = Stack<Int>().also{it.add(0)}
    val result = Array(tree.size){-1 to -1}
    var step = 0
    while (stack.isNotEmpty()) {
        val top = stack.pop()
        if (top >= 0) {
            result[top] = result[top].copy(first = step++)
            stack.push(-top - 1)
            for (next in tree.neighbors(top)) if (result[next].first == -1) {
                stack.push(next)
            }
        }else {
            result[-top-1] = result[-top-1].copy(second = step++)
        }
    }
    return result
}
fun calDFSPrev(nodes: List<List<Int>>): IntArray {
    val stack = Stack<Pair<Int, Int>>().also{it.add(0 to -1)}
    val result = IntArray(nodes.size){-1}
    while (stack.isNotEmpty()) {
        val (top, prev) = stack.pop()
        if (result[top] != -1) continue
        result[top] = prev
        for (next in nodes[top]) if (next != prev){
            stack.push(next to top)
        }
    }
    return result
}
data class Order(val forward: ArrayList<Int>, val backward: ArrayList<Int>)
fun <T> List<T>.lowerBound(predicate: (T) -> Boolean): Int {
    var min = 0
    var max = size
    while (min < max) {
        val mid = (min + max) / 2
        if (predicate(get(mid))) min = mid + 1
        else max = mid
    }
    return max
}
fun makeConveyor(tree: Tree, orders: List<Order>): IntArray? {
    val dfsOrder = calETOrder(tree)
    val height = IntArray(tree.size){-1}.also{it[0] = tree.size * 2}
    val stack = Stack<Int>().also{it.add(0)}
    while(stack.isNotEmpty()) {
        val top = stack.pop()
        val (forward, backward) = orders[top]
        forward.remove(top)
        backward.remove(top)
        forward.sortBy { dfsOrder[it].first }
        backward.sortBy { dfsOrder[it].first }
        for (next in tree.neighbors(top)) if (height[next] == -1) {
            val forwardBegin = forward.lowerBound{
                dfsOrder[it].first < dfsOrder[top].first
            }
            val forwardEnd = forward.lowerBound {
                dfsOrder[it].first < dfsOrder[top].second
            }
            val backwardBegin = backward.lowerBound {
                dfsOrder[it].first < dfsOrder[top].first
            }
            val backwardEnd = backward.lowerBound {
                dfsOrder[it].first < dfsOrder[top].second
            }
            if (forwardBegin != forwardEnd && backwardBegin != backwardEnd) return null
            if (forwardBegin != forwardEnd) height[next] = height[top] - 1
            else height[next] = height[top] + 1
            for (o in forwardBegin until forwardEnd) if (forward[o] != next) {
                orders[next].forward.add(forward[o])
            }
            for (o in backwardBegin until backwardEnd) if (backward[o] != next) {
                orders[next].backward.add(backward[o])
            }
            stack.push(next)
        }
    }
    return height
}




Measured memory_bytes: 135512