#include #define INF 1e18 #define int long long #define rep(i,l,r) for(int i=(l);i<=(r);++i) #define Rep(i,l,r) for(int i=(l);i>=(r);--i) #define gc getchar() #define pii pair #define mp(x,y) make_pair((x),(y)) using namespace std; namespace fastIO{ int read(){ int x=0,f=1;char ch=gc; while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=gc; } while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc; return x*f; } } using namespace fastIO; int n,m,q; int a[1000009],b[1000009]; vector pos[1000009]; int nw[1000009]; int l[1000009],r[1000009],k[1000009]; vector qr[1000009]; int ans[1000009]; signed main(){ // freopen("perm.in","r",stdin); // freopen("perm.out","w",stdout); n=read(),m=read(),q=read(); rep(i,1,n){ pos[i].push_back(mp(0LL,i)); nw[i]=i; } rep(i,1,m){ a[i]=read(),b[i]=read(); swap(nw[a[i]],nw[b[i]]); pos[nw[a[i]]].push_back(mp(i,a[i])); pos[nw[b[i]]].push_back(mp(i,b[i])); } rep(i,1,q){ l[i]=read(),r[i]=read(),k[i]=read(); qr[r[i]].push_back(i); } rep(i,1,n) nw[i]=i; rep(i,1,m){ swap(nw[a[i]],nw[b[i]]); for(auto u:qr[i]){ int np=nw[k[u]]; auto pt=lower_bound(pos[np].begin(),pos[np].end(),mp(l[u],0LL)); pt--; ans[u]=pt->second; } } rep(i,1,q) cout<