#include <bits/stdc++.h>
using namespace std;
int T, t, n, m;
int cnt, head[200005], tag[200005];
struct edge {
  int y, next;
} e[400005];
struct h {
  int l, r;
} a[200005];
void addedge(int x, int y) {
  e[++cnt] = edge{y, head[x]};
  head[x] = cnt;
  e[++cnt] = edge{x, head[y]};
  head[y] = cnt;
}
bool dfs(int x) {
  int q = ((tag[x] == 1) ? 2 : 1);
  for (int i = head[x]; i; i = e[i].next) {
    if (!tag[e[i].y]) {
      tag[e[i].y] = q;
      if (!dfs(e[i].y)) return 0;
    } else if (tag[e[i].y] != q)
      return 0;
  }
  return 1;
}
int main() {
  scanf("%d%d%d%d", &t, &T, &n, &m);
  int s1 = 0, s2 = 1e9;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].l, &a[i].r);
    s1 = max(s1, a[i].l);
    s2 = min(s2, a[i].r);
  }
  if (s1 + s2 > T) s2 = T - s1;
  if (s1 + s2 < t) s1 = t - s2;
  if (s1 < 0 || s2 < 0) {
    printf("IMPOSSIBLE\n");
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
  }
  bool f = 1;
  for (int i = 1; i <= n; i++) {
    bool f1 = (s1 >= a[i].l && s1 <= a[i].r),
         f2 = (s2 >= a[i].l && s2 <= a[i].r);
    if (!f1 && !f2) {
      f = 0;
      break;
    }
    if (f1 && f2) continue;
    tag[i] = (f1 ? 1 : 2);
  }
  for (int i = 1; i <= n; i++)
    if (tag[i])
      if (!dfs(i)) {
        f = 0;
        break;
      }
  for (int i = 1; i <= n; i++)
    if (!tag[i]) {
      tag[i] = 1;
      if (!dfs(i)) {
        f = 0;
        break;
      }
    }
  if (!f)
    printf("IMPOSSIBLE\n");
  else {
    printf("POSSIBLE\n");
    printf("%d %d\n", s1, s2);
    for (int i = 1; i <= n; i++) printf("%d", tag[i]);
    printf("\n");
  }
  return 0;
}
