//pB
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<int, int>
#define S second
#define F first
const int maxn = 3e5 + 10;
const int inf = 1e9;
int n, m, k;
vector<int> must[maxn], ban[maxn];
int out[maxn];
vector<pii> ans;
int vis[maxn];
set<int> st, st2; // 還沒到的
int no[maxn];
int have[maxn];
void dfs(int x, int last){
for(int y: must[x]){
if(vis[y]==2) continue;
st.erase(y);
vis[y]=2;
dfs(y, x);
}
for(int y: ban[x]){
no[y]=x;
}
vector<int> temp;
auto it=st.begin();
while(it!=st.end() ){
if(no[*it]!=x){
temp.push_back(*it);
it=st.erase(it);
}else it=next(it);
}
for(int y: temp) vis[y]=2, dfs(y, x);
}
bool dfs2(int x, int last){
//cout<<last<<" "<<x<<"\n";
for(int y: must[x]){
if(vis[y]==3) return 0;
st2.erase(y);
vis[y]=3;
ans.push_back({x, y});
if( dfs2(y, x)==0 ) return 0;
}
for(int y: ban[x]){
no[y]=x;
}
vector<int> temp;
auto it=st2.begin();
while(it!=st2.end() ){
if(no[*it]!=x){
temp.push_back(*it);
it=st2.erase(it);
}else it=next(it);
}
for(int y: temp){
vis[y]=3;
ans.push_back({x, y});
if( dfs2(y, x)==0 ) return 0;
}
return 1;
}
bool solve(int last){
// for(int i=0; i<n; i++) st2.insert(i);
st2.erase(last);
vis[last]=3;
if( dfs2(last, last) == 0 ) return 0;
if(ans.size()!=n-1) return 0;
return 1;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>k;
while(m--){
int a, b; cin>>a>>b;
must[b].push_back(a);
out[a]++;
have[a]++;
// cout<<a<<" "<<b<<"!!!\n";
}
while(k--){
int a, b; cin>>a>>b;
ban[b].push_back(a);
}
queue<int> q;
for(int i=0; i<n; i++){
if(out[i]>=2){
cout<<"NO";
return 0;
}
if(out[i]==0) q.push(i), vis[i]=1;
}
while(!q.empty()){
auto x=q.front(); q.pop();
for(int y: must[x]){
out[y]--;
if(out[y]==0) q.push(y), vis[y]=1;
}
}
for(int i=0; i<n; i++){
no[i]=-1;
if(vis[i]==0){
cout<<"NO";
return 0;
}
if(have[i]) continue;
st.insert(i);
st2.insert(i);
}
int last=0;
for(int i=0; i<n; i++){
if(vis[i]==2) continue;
st.erase(i);
vis[i]=2;
dfs(i, i);
last=i;
}
// cout<<last<<"\n";
if( solve(last) ){
for(auto[a, b]: ans) cout<<b<<" "<<a<<"\n";
}else cout<<"NO";
}