#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int L, R, n, m;
int l[N], r[N], vv[N];
int fa[N], v[N], fav[N];
int get(int x) {
  if (x == fa[x]) return x;
  int tmp = get(fa[x]);
  v[x] = v[fa[x]] ^ fav[x];
  fav[x] = v[x] ^ v[tmp];
  return fa[x] = tmp;
}
void GG() {
  puts("IMPOSSIBLE");
  exit(0);
}
void merge(int x, int y) {
  int xx = get(x), yy = get(y);
  if (xx != yy)
    fa[xx] = yy, fav[xx] = v[x] ^ v[y] ^ 1;
  else if (v[x] ^ v[y] ^ 1)
    GG();
}
void sett(int x, int y) {
  int xx = get(x);
  if (vv[xx] == -1)
    vv[xx] = y ^ v[x];
  else if (vv[xx] ^ y ^ v[x])
    GG();
}
int main() {
  scanf("%d%d%d%d", &L, &R, &n, &m);
  int n1 = 0, n2 = 1 << 30;
  for (int i = (int)(1); i <= (int)(n); i++) {
    scanf("%d%d", &l[i], &r[i]);
    n1 = max(n1, l[i]);
    n2 = min(n2, r[i]);
  }
  if (n1 + n2 < L) n1 += L - n1 - n2;
  if (n1 + n2 > R) n2 -= n1 + n2 - R;
  if (n1 < 0 || n2 < 0) GG();
  for (int i = (int)(1); i <= (int)(n); i++) fa[i] = i, vv[i] = -1;
  for (int i = (int)(1); i <= (int)(m); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    merge(x, y);
  }
  for (int i = (int)(1); i <= (int)(n); i++) {
    if (n1 < l[i] || n1 > r[i]) sett(i, 1);
    if (n2 < l[i] || n2 > r[i]) sett(i, 0);
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    if (vv[i] == -1) vv[i] = 0;
  printf("POSSIBLE\n%d %d\n", n1, n2);
  for (int i = (int)(1); i <= (int)(n); i++)
    get(i), putchar(v[i] ^ vv[fa[i]] ? '2' : '1');
}
