#include <bits/stdc++.h>
using namespace std;
int n, m, t, T, l[100000 + 5], r[100000 + 5], c[100000 + 5], ee,
    lnk[100000 + 5];
struct edge {
  int to, nxt;
} e[2 * 100000 + 5];
inline void Col(const int& x) {
  for (register int i = lnk[x]; i; i = e[i].nxt)
    c[e[i].to] == c[x]
        ? (puts("IMPOSSIBLE"), exit(0), 0)
        : !c[e[i].to] && (c[e[i].to] = 3 - c[x], Col(e[i].to), 0);
}
int main() {
  register int i, x, y, L = 0, R = 1e9;
  scanf("%d%d%d%d", &t, &T, &n, &m);
  for (i = 1; i <= n; ++i)
    scanf("%d%d", l + i, r + i), L = max(L, l[i]), R = min(R, r[i]);
  for (i = 1; i <= m; ++i)
    scanf("%d%d", &x, &y), (e[++ee].nxt = lnk[x], e[lnk[x] = ee].to = y),
        (e[++ee].nxt = lnk[y], e[lnk[y] = ee].to = x);
  if (L + R > T && (R = T - L), L + R < t && (L = t - R),
      L < 0 || L > T || R < 0 || R > T)
    return puts("IMPOSSIBLE"), 0;
  for (i = 1; i <= n; ++i)
    if (!((l[i]) <= (L) && (L) <= (r[i])) && !((l[i]) <= (R) && (R) <= (r[i])))
      return puts("IMPOSSIBLE"), 0;
    else if (!((l[i]) <= (R) && (R) <= (r[i]))) {
      if (c[i] == 2) return puts("IMPOSSIBLE"), 0;
      c[i] = 1, Col(i);
    } else if (!((l[i]) <= (L) && (L) <= (r[i]))) {
      if (c[i] == 1) return puts("IMPOSSIBLE"), 0;
      c[i] = 2, Col(i);
    }
  for (i = 1; i <= n; ++i) !c[i] && (c[i] = 2, Col(i), 0);
  for (puts("POSSIBLE"), printf("%d %d\n", L, R), i = 1; i <= n; ++i)
    putchar(c[i] + 48);
  return 0;
}
