#include <bits/stdc++.h>
using namespace std;
#define sz(v) (int)v.size()
const int MAXN = 3*1e5+5;
vector<int> adj[MAXN], ansu, ansv;
set< pair<int,int> > st;
set<int> testar;
int marc[MAXN], cur, ruim;
void dfs(int s){
if(sz(adj[s]) > 1)ruim = 1;
marc[s] = cur;
for(int viz : adj[s]){
if(!marc[viz])dfs(viz);
if(marc[viz] == cur)ruim = 1;
}
}
void dfs2(int s){
testar.erase(s);
vector<int> nxt;
for(int viz : testar)
if(st.find({viz,s}) == st.end()) nxt.push_back(viz);
for(int viz : nxt)dfs2(viz);
}
void check(int s){
testar.erase(s);
vector<int> nxt;
for(int viz : testar)
if(st.find({viz,s}) == st.end()){
ansu.push_back(viz); ansv.push_back(s);
nxt.push_back(viz);
}
for(int viz : nxt)check(viz);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,k; cin>>n>>m>>k;
for(int i = 0; i < m; i++){
int a,b; cin>>a>>b;
adj[a].push_back(b);
ansu.push_back(a); ansv.push_back(b);
}
for(int i = 0; i < k; i++){
int c,d; cin>>c>>d;
st.insert({c,d});
}
for(int i = 0; i < n; i++){
if(!marc[i]){
cur++;
dfs(i);
}
if(sz(adj[i]) == 0)testar.insert(i);
}
if(ruim){cout<<"NO\n"; return 0;}
for(int i = 0; i < n; i++)
if(testar.find(i) != testar.end()){
dfs2(i);
if(testar.empty()){
for(int j = 0; j < n; j++)
if(sz(adj[j]) == 0)testar.insert(j);
check(i);
break;
}
}
if(!testar.empty())cout<<"NO\n";
else{
for(int i = 0; i < n-1; i++)cout<<ansu[i]<<" "<<ansv[i]<<"\n";
}
}