#include <bits/stdc++.h>
using namespace std;
int T, t, n, m, mn = 0x3f3f3f3f, mx = 0, L[100000 + 5], R[100000 + 5],
                col[100000 + 5];
template <class T>
void read(T &x) {
  char ch;
  bool ok;
  for (ok = 0, ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') ok = 1;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  if (ok) x = -x;
}
int fa[2 * 100000 + 5], to[100000 + 5];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  read(t);
  read(T);
  read(n);
  read(m);
  for (int i = (1), en = (n); i <= en; ++i) {
    read(L[i]);
    read(R[i]);
    mn = min(mn, R[i]);
    mx = max(mx, L[i]);
  }
  if (mn + mx < t) mx = t - mn;
  if (mn + mx > T) mn = T - mx;
  if (mn + mx < t || mn + mx > T || mn < 0) {
    puts("IMPOSSIBLE");
    return 0;
  };
  for (int i = (1), en = (2 * n); i <= en; ++i) fa[i] = i;
  for (int i = (1), en = (m); i <= en; ++i) {
    int u, v;
    read(u);
    read(v);
    if (find(u) == find(v)) {
      puts("IMPOSSIBLE");
      return 0;
    }
    fa[find(n + u)] = find(v);
    fa[find(n + v)] = find(u);
  }
  for (int i = (1), en = (n); i <= en; ++i)
    if (find(n + i) != n + i) to[find(n + i)] = find(i);
  for (int i = (1), en = (n); i <= en; ++i)
    L[find(i)] = max(L[find(i)], L[i]), R[find(i)] = min(R[find(i)], R[i]);
  for (int i = (1), en = (n); i <= en; ++i)
    if (find(i) == i) {
      if (L[i] > R[i]) {
        puts("IMPOSSIBLE");
        return 0;
      }
      if (!to[i]) {
        if (mn >= L[i] && mn <= R[i])
          col[i] = 1;
        else if (mx >= L[i] && mx <= R[i])
          col[i] = 2;
        else {
          puts("IMPOSSIBLE");
          return 0;
        }
      } else {
        if (mn >= L[i] && mn <= R[i] && mx >= L[to[i]] && mx <= R[to[i]]) {
          col[i] = 1;
          col[to[i]] = 2;
        } else if (mn >= L[to[i]] && mn <= R[to[i]] && mx >= L[i] &&
                   mx <= R[i]) {
          col[i] = 2;
          col[to[i]] = 1;
        } else {
          puts("IMPOSSIBLE");
          return 0;
        }
      }
    }
  puts("POSSIBLE");
  printf("%d %d\n", mn, mx);
  for (int i = (1), en = (n); i <= en; ++i) printf("%d", col[find(i)]);
  return 0;
}
