#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define g0(x) get<0>(x)
#define g1(x) get<1>(x)
#define g2(x) get<2>(x)
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define int long long
#define f first
#define s second
#define pll pair<long long, long long>
#define iii tuple<int,int,int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
signed main(){
cout<<"NO";
return;
int n,m,k;cin>>n>>m>>k;
vector<vector<int>> oal(n), oral(n);
for(int i=0;i<m;i++){
int a,b;cin>>a>>b;
oal[a].pb(b);
oral[b].pb(a);
}
vector<pll> fball(k), fb;
vector<vector<int>> cant(n);
for(int i=0;i<k;i++){
cin>>fball[i].f>>fball[i].s;
}
vector<int> head(n+1, 0), vis(n, 0);
int headcnt=0;
for(int i=0;i<n;i++){
if(sz(oal[i]) > 1) {
cout<<"NO";
return 0;
}
if(sz(oal[i]) == 0){
head[i]=1;
headcnt++;
//printf("at %lld\n", i);
bool die=0;
auto dfs=[&](auto dfs, int x, vector<vector<int>> & to) -> void{
vis[x]=1;
for(auto it : to[x]){
if(vis[it]){
die=1;
break;
}
dfs(dfs, it, to);
}
if(die)return;
};
dfs(dfs, i, oral);
if(die){
cout<<"NO";
return 0;
}
}
}
for(int i=0;i<n;i++){
if(!vis[i]){
cout<<"NO";
return 0;
}
}
for(int i=0;i<k;i++){
if(head[fball[i].f] and head[fball[i].s]) fb.pb(fball[i]);
}
k=sz(fb);
for(int i=0;i<k;i++){
cant[fb[i].s].pb(fb[i].f);
}
for(int i=0;i<n;i++) {
cant[i].pb(-1);
cant[i].pb(n);
sort(all(cant[i]));
}
auto al=oal, ral=oral;
auto solve=[&](int root)->bool{
set<int> s;
int cnt=0;
for(int i=0;i<n;i++){
if(i != root and head[i])s.insert(i);
}
queue<int> q;
q.push(root);
while(!q.empty()){
auto x=q.front(); q.pop();
//printf("x %lld\n",x );
cnt++;
for(int i=0;i<sz(cant[x])-1;i++){
int l=cant[x][i], r=cant[x][i+1];
//printf("l %lld, r %lld\n", l, r);
auto it = s.upper_bound(l);
while(it != s.end()){
if(*it >= r)break;
int fr=*it;
//printf("fr is %lld\n", fr);
al[fr].pb(x);
ral[x].pb(fr);
q.push(fr);
it=s.erase(it);
}
}
}
if(cnt == headcnt)return 1;
else return 0;
};
bool res=solve((fb.empty()? 0 : fb.back().f));
if(res){
for(int i=0;i<n;i++){
assert(sz(al[i]) <= 1);
for(auto it : al[i]) cout<<i<<" "<<it<<'\n';
}
}
else {
cout<<"NO";
}
}