#include <bits/stdc++.h>
using namespace std;
struct ii {
  int x, y;
  ii(int x = 0, int y = 0) : x(x), y(y) {}
  bool operator<(const ii &a) const {
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
  bool operator==(const ii &a) const { return x == a.x && y == a.y; }
  ii friend operator+(ii a, ii b) { return ii(a.x + b.x, a.y + b.y); }
  ii friend operator-(ii a, ii b) { return ii(a.x - b.x, a.y - b.y); }
};
template <class T>
void sc(T &x) {
  x = 0;
  char c;
  int f = 1;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = x * 10 + (c ^ 48);
  while (c = getchar(), c > 47);
  x *= f;
}
template <class T>
void nt(T x) {
  if (!x) return;
  nt(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
void pt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x)
    putchar('0');
  else
    nt(x);
}
template <class T>
void pts(T x) {
  pt(x);
  putchar(' ');
}
template <class T>
void ptn(T x) {
  pt(x);
  putchar('\n');
}
template <class v>
void pp(v x, int y) {
  static char ch[] = {" \n"};
  pt(x);
  putchar(ch[y]);
}
template <class T>
void PP(T *x, int y) {
  for (int i = 0, i_ = y; i < i_; ++i) pp(x[i], i == y - 1);
}
template <class T>
void Max(T &x, T y) {
  if (x < y) x = y;
}
template <class T>
void Min(T &x, T y) {
  if (x > y) x = y;
}
int t, T, n, m;
const int maxn = 100005;
int l[maxn], r[maxn];
int hs[maxn * 4], tot;
const int maxV = 1800005;
const int maxE = 10000005;
int point[maxE], nextp[maxE], head[maxV], ecnt;
void ins(int u, int v) {
  point[++ecnt] = v;
  nextp[ecnt] = head[u];
  head[u] = ecnt;
}
void inses(int u, int v) {
  ins(u, v);
  ins(v ^ 1, u ^ 1);
}
int id(int u, int v, int w) { return (tot * u + v) << 1 | w; }
int lo(int x) { return lower_bound(hs, hs + tot, x) - hs; }
int up(int x) { return upper_bound(hs, hs + tot, x) - hs; }
int dfn[maxV], col[maxV], dfs_clock, col_clock;
int s[maxV], top;
int dfs(int x) {
  int low = dfn[x] = ++dfs_clock;
  s[++top] = x;
  for (int i = head[x]; i; i = nextp[i]) {
    int to = point[i];
    if (!dfn[to])
      Min(low, dfs(to));
    else if (!col[to])
      Min(low, dfn[to]);
  }
  if (low == dfn[x]) {
    ++col_clock;
    while (true) {
      int t = s[top--];
      assert(!col[t]);
      col[t] = col_clock;
      if (t == x) break;
    }
  }
  return low;
}
void FAIL() {
  puts("IMPOSSIBLE");
  exit(0);
}
int main() {
  sc(t);
  sc(T);
  sc(n);
  sc(m);
  for (int i = 0, i_ = n; i < i_; ++i) {
    sc(l[i]);
    sc(r[i]);
    if (l[i] > T) FAIL();
    if (r[i] > T) r[i] = T;
    hs[tot++] = l[i];
    hs[tot++] = r[i];
    if (l[i] < t) hs[tot++] = t - l[i];
    if (r[i] < t) hs[tot++] = t - r[i];
  }
  hs[tot++] = 0;
  hs[tot++] = T;
  sort(hs, hs + tot);
  tot = unique(hs, hs + tot) - hs;
  for (int i = 0, i_ = tot; i < i_; ++i) {
    if (hs[i] < t) {
      int b = up(t - hs[i] - 1) - 1;
      assert(b >= 0);
      for (int j = 0, j_ = 2; j < j_; ++j) inses(id(j, i, 1), id(j ^ 1, b, 0));
    }
    if (i + 1 < tot) {
      int b = up(T - hs[i + 1]) - 1;
      if (b >= 0)
        for (int j = 0, j_ = 2; j < j_; ++j)
          inses(id(j, i, 0), id(j ^ 1, b, 1));
      for (int j = 0, j_ = 2; j < j_; ++j) inses(id(j, i, 1), id(j, i + 1, 1));
    }
  }
  for (int j = 0, j_ = 2; j < j_; ++j)
    inses(id(j, tot - 1, 0), id(j, tot - 1, 1));
  for (int i = 0, i_ = n; i < i_; ++i) {
    l[i] = up(l[i] - 1) - 1;
    r[i] = lo(r[i]);
    for (int j = 0, j_ = 2; j < j_; ++j) {
      if (l[i] >= 0) inses(id(2, i, j), id(j ^ 1, l[i], 0));
      if (r[i] >= 0) inses(id(2, i, j), id(j ^ 1, r[i], 1));
    }
  }
  for (int i = 0, i_ = m; i < i_; ++i) {
    int u, v;
    sc(u);
    sc(v);
    --u;
    --v;
    for (int j = 0, j_ = 2; j < j_; ++j) inses(id(2, u, j), id(2, v, j ^ 1));
  }
  int nn = id(2, n, 0);
  assert(nn <= maxV);
  assert(ecnt < maxE);
  for (int i = 0, i_ = nn; i < i_; ++i)
    if (!dfn[i]) dfs(i);
  for (int i = 0; i < nn; i += 2)
    if (col[i] == col[i ^ 1]) FAIL();
  int cnt[] = {-1, -1};
  for (int i = 0, i_ = 2; i < i_; ++i) {
    for (int j = 0, j_ = tot; j < j_; ++j)
      if (col[id(i, j, 1)] < col[id(i, j, 0)]) {
        cnt[i] = hs[j];
        break;
      }
    assert(cnt[i] != -1);
  }
  puts("POSSIBLE");
  for (int i = 0, i_ = 2; i < i_; ++i) pp(cnt[i], i == 1);
  for (int i = 0, i_ = n; i < i_; ++i) {
    char t;
    if (col[id(2, i, 1)] < col[id(2, i, 0)])
      t = '1';
    else
      t = '2';
    putchar(t);
  }
  puts("");
  return 0;
}
