#include <bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
const int INF=1e6+5;
struct _node_edge{
int to_,next_,disv_;
}edge[INF<<1];
int n,m,pre[INF],tot,head[INF],now[INF],dfn[INF],kmp[INF];
int low[INF],s[INF],r,f[INF],vis[INF];
vector < int > e[INF],e2[INF];
void add_edge(int x,int y,int z) {
edge[++tot]={y,head[x],z};
head[x]=tot;
}
void tarjan(int x,int fa) {
dfn[x]=low[x]=++tot;s[++r]=x;f[x]=1;
for (int i=head[x];i;i=edge[i].next_) {
int v=edge[i].to_;
if (v==fa) continue;
if (!dfn[v]) {
tarjan(v,x);
low[x]=min(low[x],low[v]);
}
else if (f[v])
low[x]=min(low[x],dfn[v]);
}
if (dfn[x]==low[x]) {
int xx=s[r];f[xx]=0;r--;
while (xx!=x) {
xx=s[r];f[xx]=0;
r--;
}
}
}
int sum=0,sumn=0,cnt[INF],cnt2[INF];
void DFS(int x) {
if (vis[x]) return ;
cnt[++cnt[0]]=pre[x];
cnt2[++cnt2[0]]=now[x];
vis[x]=1;sumn++;
sum+=e[x].size();
for (int v:e[x]) {
DFS(v);
}
}
namespace S{
int dfn[INF],low[INF],f[INF],tot,s[INF],r,Max,vis2[INF],fl=0,vis3[INF];
void tarjan(int x) {
aa[++aa[0]]=pre[x];
dfn[x]=low[x]=++tot;s[++r]=x;Max=max(Max,r);
for (int v:e[x]) {
if (!dfn[v]) {
tarjan(v);
if (low[v]>=dfn[x]) {
vector <int> cnt;
int M=0,N=0;
while (s[r+1]!=v) {
int xx=s[r];r--;
cnt.pb(xx);vis2[xx]=1;N++
}
vis2[x]=1;N++;
for (int xx:cnt) {
int len=e[xx].size();
for (int q=0;q<len;q++) {
if (vis3[e2[xx][q]]) continue;
vis3[e2[xx][q]]=1;
M++;
}
}
if (N==M && N%2==1) fl=1;
for (int i:cnt) vis2[i]=0;
vis2[x]=0;
}
low[x]=min(low[x],low[v]);
}
else low[x]=min(low[x],dfn[v]);
}
}
void main(int x) {
Max=0;tarjan(x);
for (int i=1;i<=Max;i++) s[i]=0;
}
}
signed main()
{
freopen("zoo.in","r",stdin);
freopen("zoo.out","w",stdout);
ios::sync_with_stdio(false);
cin>>n>>m;
for (int i=1;i<=n;i++) cin>>pre[i]>>now[i];
for (int i=1;i<=m;i++) {
int x=0,y=0;
cin>>x>>y;
add_edge(x,y,i);
add_edge(y,x,i);
}
tot=0;
for (int i=1;i<=n;i++)
if (!dfn[i]) tarjan(i,0);
for (int x=1;x<=n;x++) {
for (int i=head[x];i;i=edge[i].next_) {
int a=x,b=edge[i].to_,d=edge[i].disv_;
if (dfn[a]>dfn[b]) swap(a,b);
if (dfn[a]<low[b]) ;
else e[x].pb(edge[i].to_),e2[x].pb(d);
}
}
for (int x=1;x<=n;x++) {
if (vis[x]) continue;
sum=sumn=cnt[0]=cnt2[0]=0;
DFS(x);
if (sum/2==sumn) {
int j=0;
for (int i=2;i<=cnt2[0];i++) {
while (j && cnt2[j+1]!=cnt2[i]) j=kmp[j];
if (cnt2[j+1]==cnt[i]) kmp[i]=++j;
else kmp[i]=0;
}
for (int i=1;i<=cnt[0];i++) cnt[cnt[0]+i]=cnt[i];
j=0;int fl=0;
for (int i=1;i<=cnt[0]*2;i++) {
while (j && cnt2[j+1]!=cnt[i]) j=kmp[j];
if (cnt2[j+1]==cnt[i]) j++;
if (j==cnt2[0]) {
fl=1;
break;
}
}
if (!fl) {cout<<"impossible\n";return 0;}
}
else {
sort(cnt+1,cnt+1+cnt[0]);
sort(cnt2+1,cnt2+1+cnt2[0]);
int fl=0;
for (int i=1;i<=cnt[0];i++)
if (cnt[i]!=cnt2[i]) fl=1;
int fl2=0;
for (int i=2;i<=cnt[0];i++)
if (cnt[i-1]==cnt[i]) fl2=1;
if (fl) {cout<<"impossible\n";return 0;}
if (!fl2) S::main(x);
}
}
cout<<"possible\n";
return 0;
}