#include <bits/stdc++.h>
using namespace std;
template <class free>
inline void Max(free&, free);
template <class free>
inline void Min(free&, free);
struct inter {
  int l, r, id;
  inline void operator^=(const inter x) { Max(l, x.l), Min(r, x.r); }
  inline bool in(int x) { return l <= x && x <= r; }
} I[200050], I1[200050][2];
struct point {
  int next, to;
} ar[200050];
bool a1[200050];
int head[200050], art, a[200050], at;
inline bool dfs(int, int);
inline void read(int&), link(int, int);
int main() {
  int t, T, n, m, n1(0x3f3f3f3f), n2(-0x3f3f3f3f);
  read(t), read(T), read(n), read(m);
  for (int i(1); i <= n; ++i)
    read(I[i].l), read(I[i].r), Min(n1, I[i].r), Max(n2, I[i].l),
        I1[i][0] = I1[i][1] = {0, 0x3f3f3f3f};
  if (n1 + n2 < t)
    n2 += t - n1 - n2;
  else if (n1 + n2 > T)
    n1 += T - n1 - n2;
  for (int i(1), u, v; i <= m; ++i) read(u), read(v), link(u, v);
  memset(a, -1, sizeof(a));
  for (int i(1); i <= n; ++i)
    if (!~a[i] && dfs((++at, i), 0)) return puts("IMPOSSIBLE"), 0;
  for (int i(1); i <= at; ++i)
    if (I1[i][0].in(n1) && I1[i][1].in(n2))
      a1[i] = 0;
    else if (I1[i][1].in(n1) && I1[i][0].in(n2))
      a1[i] = 1;
    else
      return puts("IMPOSSIBLE"), 0;
  puts("POSSIBLE");
  printf("%d %d\n", n1, n2);
  for (int i(1); i <= n; ++i) putchar(a1[I[i].id] ^ a[i] ? 50 : 49);
  return 0;
}
inline bool dfs(int x, int c) {
  I1[at][a[x] = c] ^= I[x], I[x].id = at;
  for (int i(head[x]), i1; i; i = ar[i].next)
    if (!~a[i1 = ar[i].to] && dfs(i1, c ^ 1))
      return true;
    else if (a[i1] == c)
      return true;
  return false;
}
template <class free>
inline void Max(free& x, free y) {
  x = x > y ? x : y;
}
template <class free>
inline void Min(free& x, free y) {
  x = x < y ? x : y;
}
inline void link(int u, int v) {
  ar[++art] = {head[u], v}, head[u] = art;
  ar[++art] = {head[v], u}, head[v] = art;
}
inline void read(int& x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
