// author : black_trees#include<cmath>#include<queue>#include<cstdio>#include<vector>#include<cstring>#include<utility>#include<iostream>#include<algorithm>#define endl '\n'#define int long longusingnamespacestd;usingi64=longlong;constintsi=2e5+10;intn,m,k;inttot=0,head[si];structEdge{intver,Next;}e[si<<1];inlinevoidadd(intu,intv){e[tot]=(Edge){v,head[u]},head[u]=tot++;}intp[si],h[si];std::vector<int>c;intans=0,mx[si];std::priority_queue<std::pair<int,int>>q;signedmain(){cin.tie(0)->sync_with_stdio(false);cin.exceptions(cin.failbit|cin.badbit);memset(head,-1,sizeofhead);cin>>n>>m>>k;for(inti=1;i<=m;++i){intu,v;cin>>u>>v;add(u,v),add(v,u);}memset(mx,-1,sizeofhead);for(inti=1;i<=k;++i)cin>>p[i]>>h[i];for(inti=1;i<=k;++i)if(mx[p[i]]<h[i])q.push(make_pair(mx[p[i]]=h[i],p[i]));while(!q.empty()){auto[val,u]=q.top();q.pop();if(mx[u]!=val)continue;for(inti=head[u];~i;i=e[i].Next){intv=e[i].ver;if(mx[v]<val-1)q.push(make_pair(mx[v]=val-1,v));}}c.clear();for(inti=1;i<=n;++i)if(~mx[i])c.emplace_back(i);cout<<c.size()<<endl;for(autox:c)cout<<x<<" ";cout<<endl;return0;}