#include <bits/stdc++.h>
using namespace std;
const int N = 100005, INF = 1e9;
struct edge {
  int to, nxt;
} e[N << 1];
int n, m, head[N], cnt, tl, tr, col[N], x, y, A, B;
bool vis[N];
struct interval {
  int l, r;
  friend inline bool operator<(const interval& A, const interval& B) {
    return A.l != B.l ? A.l < B.l : A.r < B.r;
  }
} a[N];
inline void addedge(const int& x, const int& y) {
  e[++cnt] = (edge){y, head[x]};
  head[x] = cnt;
  e[++cnt] = (edge){x, head[y]};
  head[y] = cnt;
}
inline bool paint(const int& now) {
  vis[now] = 1;
  for (register int i = head[now]; i; i = e[i].nxt) {
    if (~col[e[i].to] && col[e[i].to] == col[now]) return 0;
    if (~col[now] && !~col[e[i].to])
      if (col[e[i].to] = col[now] ^ 1, !paint(e[i].to)) return 0;
  }
  return 1;
}
int main() {
  register int i;
  for (scanf("%d%d%d%d", &tl, &tr, &n, &m), B = INF, i = 1; i <= n; ++i)
    scanf("%d%d", &a[i].l, &a[i].r), A = max(A, a[i].l), B = min(B, a[i].r),
                                     col[i] = -1;
  for (i = 1; i <= m; ++i) scanf("%d%d", &x, &y), addedge(x, y);
  if (A + B < tl) A += tl - (A + B);
  if (A + B > tr) B -= A + B - tr;
  if (B < 0) return puts("IMPOSSIBLE"), 0;
  for (i = 1; i <= n; ++i) {
    if (a[i].l <= A && A <= a[i].r && a[i].l <= B && B <= a[i].r) continue;
    if (a[i].l <= A && A <= a[i].r)
      col[i] = 0;
    else if (a[i].l <= B && B <= a[i].r)
      col[i] = 1;
    else
      return puts("IMPOSSIBLE"), 0;
  }
  for (i = 1; i <= n; ++i)
    if (!vis[i] && !paint(i)) return puts("IMPOSSIBLE"), 0;
  for (i = 1; i <= n; ++i)
    if (!~col[i] && (col[i] = 0, !paint(i))) return puts("IMPOSSIBLE"), 0;
  puts("POSSIBLE");
  printf("%d %d\n", A, B);
  for (i = 1; i <= n; ++i) putchar(col[i] ? '2' : '1');
  return 0;
}
