不知道为啥 TLE 啦。
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define re register
#define il inline
#define pii pair<int,int>
#define x first
#define y second
#define gc getchar()
#define rd read()
#define debug() puts("------------")
namespace yzqwq{
il 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<<1)+(x<<3)+(ch^48),ch=gc;
return x*f;
}
il int qmi(int a,int b,int p){
int ans=1;
while(b){
if(b&1) ans=ans*a%p;
a=a*a%p,b>>=1;
}
return ans;
}
il int gcd(int a,int b){
if(!b) return a;
return gcd(b,a%b);
}
il int lcm(int a,int b){
return a/gcd(a,b)*b;
}
il void exgcd(int a,int b,int &x,int &y){
if(!b) return x=1,y=0,void(0);
exgcd(b,a%b,x,y);
int t=x;
x=y,y=t-a/b*x;
return ;
}
il int F(int n,int a,int b,int c){
//sum{|_ (ai+b)/c _| i:0~n}
if(!n) return b/c;
if(!a) return (n+1)*(b/c);
if(a>=c||b>=c){
int x=a/b,y=b/c;
return n*(n+1)/2*x+(n+1)*y+F(n,a%c,b%c,c);
}
int m=(a*n+b)/c;
return n*m+F(m-1,c,c-b+1,a);
}
struct lb{
int d[64];
il void print(){
for(re int i=0;i<63;++i)
if(d[i]) printf("%lld:%lld\n",i,d[i]);
return ;
}
lb(){memset(d,0,sizeof(d));}
il void operator +=(int x){
for(re int i=62;i>=0;--i){
if(!(x&(1ll<<i))) continue;
if(d[i]) x^=d[i];
else return d[i]=x,void(0);
}
return ;
}
int& operator [](int x){
return d[x];
}
il void operator +=(lb &x){
for(re int i=62;i>=0;--i)
if(x[i]) *this+=x[i];
return ;
}
il friend lb operator +(lb &x,lb &y){
lb z=x;
for(re int i=62;i>=0;--i)
if(y[i]) z+=y[i];
return z;
}
il int Max_calc(){
int ans=0;
for(re int i=62;i>=0;--i)
if((ans^d[i])>ans) ans^=d[i];
return ans;
}
};
mt19937 rnd(time(0));
}
using namespace yzqwq;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
const int N=2e6+10;
int n,m;
vector<pii> v[N<<1];
struct node{
int x,y,id,f;
}st[N<<2];
int top;
int l[N],r[N];
int f[N],high[N],tag[N];
il int find(int x){
while(x!=f[x]) x=f[x];
return f[x];
}
il void merge(int x,int y,int id){
x=find(x),y=find(y);
if(x==y) return ;
if(high[x]<high[y]) swap(x,y);
st[++top]={x,y,id,high[x]==high[y]};
tag[x]-=tag[y],f[x]=y;
high[y]+=(high[x]==high[y]);
return ;
}
il void modify(int u,int l,int r,int L,int R,pii x){
if(L>R) return ;
if(l>=L&&r<=R) return v[u].push_back(x),void(0);
int mid=l+r>>1;
if(L<=mid) modify(ls(u),l,mid,L,R,x);
if(mid< R) modify(rs(u),mid+1,r,L,R,x);
return ;
}
il void upd(int u,int l,int r){
int mid=l+r>>1;
for(auto x:v[u]) merge(x.x,x.y,u);
if(l==r) ++tag[find(1)];
else upd(ls(u),l,mid),upd(rs(u),mid+1,r);
while(top&&st[top].id==u){
f[st[top].x]=st[top].x,
tag[st[top].x]+=tag[st[top].y];
high[st[top].y]-=st[top].f;
--top;
}
return ;
}
il void solve(){
n=rd,m=rd;
for(re int i=1;i<=n;++i) f[i]=i,high[i]=1;
for(re int i=1;i<=n;++i) l[i]=rd,r[i]=rd;
for(re int i=1;i<=m;++i){
int u=rd,v=rd;
modify(1,0,200000,max(l[u],l[v]),min(r[u],r[v]),{u,v});
}
upd(1,0,200000);
for(re int i=1;i<=n;++i)
if(tag[i]) printf("%lld ",i);
return ;
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int t=1;while(t--)
solve();
return 0;
}