#include <bits/stdc++.h>
using namespace std;
int n, m, T, t, n1 = 1e9, n2, l[500001], r[500001], c[500001], flag;
vector<int> g[500001];
inline void dfs(int x) {
  for (int y : g[x])
    if (!c[y])
      c[y] = 3 - c[x], dfs(y);
    else
      flag |= (c[x] == c[y]);
}
int main(void) {
  int i, x, y, p1, p2;
  scanf("%d%d%d%d", &t, &T, &n, &m);
  for (i = 1; i <= n; ++i)
    scanf("%d%d", l + i, r + i), n1 = min(n1, r[i]), n2 = max(n2, l[i]);
  if (n1 + n2 > T) n1 = T - n2;
  if (n1 + n2 < t) n2 = t - n1;
  if (n1 < 0 || n2 < 0) return puts("IMPOSSIBLE"), 0;
  for (i = 1; i <= n; ++i) {
    p1 = (n1 >= l[i] && n1 <= r[i]), p2 = (n2 >= l[i] && n2 <= r[i]);
    if (!p1 && !p2) return puts("IMPOSSIBLE"), 0;
    if (p1 && !p2) c[i] = 1;
    if (!p1 && p2) c[i] = 2;
  }
  while (m--) scanf("%d%d", &x, &y), g[x].push_back(y), g[y].push_back(x);
  for (i = 1; i <= n; ++i)
    if (c[i]) {
      dfs(i);
      if (flag) return puts("IMPOSSIBLE"), 0;
    }
  for (i = 1; i <= n; ++i)
    if (!c[i]) {
      c[i] = 1, dfs(i);
      if (flag) return puts("IMPOSSIBLE"), 0;
    }
  puts("POSSIBLE");
  printf("%d %d\n", n1, n2);
  for (i = 1; i <= n; ++i) printf("%d", c[i]);
  return 0;
}
