#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int res = 0, flag = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res * flag;
}
int t, T, n, m, l[100001], r[100001], head[100001], to[200001], nxt[200001],
    tot, x, y, n1 = (0x7fffffff), n2, ans[100001];
inline void add(int x, int y) {
  to[++tot] = y;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dfs(int x) {
  for (register int i = head[x]; i; i = nxt[i]) {
    if (ans[to[i]] == ans[x]) {
      puts("IMPOSSIBLE");
      exit(0);
    }
    if (!ans[to[i]]) {
      ans[to[i]] = 3 - ans[x];
      dfs(to[i]);
    }
  }
}
int main() {
  t = read();
  T = read();
  n = read();
  m = read();
  for (register int i = 1; i <= n; ++i) {
    l[i] = read();
    r[i] = read();
    n1 = min(n1, r[i]);
    n2 = max(n2, l[i]);
  }
  while (m--) {
    x = read();
    y = read();
    add(x, y);
    add(y, x);
  }
  if (n1 + n2 < t) n2 = t - n1;
  if (n1 + n2 > T) n1 = T - n2;
  if (n1 < 0 || n2 < 0) {
    puts("IMPOSSIBLE");
    return 0;
  }
  for (register int i = 1; i <= n; ++i) {
    if (!(l[i] <= n1 && n1 <= r[i]) && !(l[i] <= n2 && n2 <= r[i])) {
      puts("IMPOSSIBLE");
      return 0;
    }
    if (l[i] <= n1 && n1 <= r[i] && !(l[i] <= n2 && n2 <= r[i])) ans[i] = 1;
    if (!(l[i] <= n1 && n1 <= r[i]) && l[i] <= n2 && n2 <= r[i]) ans[i] = 2;
  }
  for (register int i = 1; i <= n; ++i)
    if (ans[i]) dfs(i);
  for (register int i = 1; i <= n; ++i)
    if (!ans[i]) {
      ans[i] = 1;
      dfs(i);
    }
  puts("POSSIBLE");
  printf("%d %d\n", n1, n2);
  for (register int i = 1; i <= n; ++i) printf("%d", ans[i]);
  puts("");
  return 0;
}
