#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ '0');
    ch = getchar();
  }
  return f ? x : -x;
}
const int N = 1e5 + 5;
int t, T, n, m, s1, s2, l[N], r[N], c[N];
vector<int> e[N];
inline bool dfs(int u) {
  for (int v : e[u]) {
    if (c[v]) {
      if (c[u] == c[v]) return 0;
    } else {
      c[v] = 3 - c[u];
      if (!dfs(v)) return 0;
    }
  }
  return 1;
}
int main() {
  t = read(), T = read(), n = read(), m = read();
  s1 = 0x7fffffff, s2 = 0;
  for (int i = (1), _ed = (n); i <= _ed; ++i) {
    l[i] = read(), r[i] = read();
    s1 = min(s1, r[i]), s2 = max(s2, l[i]);
  }
  if (s1 + s2 < t) s2 = t - s1;
  if (s1 + s2 > T) s1 = T - s2;
  if (s1 < 0 || s2 < 0) return puts("IMPOSSIBLE"), 0;
  for (int i = (1), _ed = (n); i <= _ed; ++i) {
    int flg1 = (l[i] <= s1 && s1 <= r[i]), flg2 = (l[i] <= s2 && s2 <= r[i]);
    if (!flg1 && !flg2) return puts("IMPOSSIBLE"), 0;
    if (flg1 && !flg2) c[i] = 1;
    if (!flg1 && flg2) c[i] = 2;
  }
  for (int i = (1), _ed = (m); i <= _ed; ++i) {
    int u = read(), v = read();
    e[u].push_back(v), e[v].push_back(u);
  }
  for (int i = (1), _ed = (n); i <= _ed; ++i)
    if (c[i])
      if (!dfs(i)) return puts("IMPOSSIBLE"), 0;
  for (int i = (1), _ed = (n); i <= _ed; ++i)
    if (!c[i]) {
      c[i] = 1;
      if (!dfs(i)) return puts("IMPOSSIBLE"), 0;
    }
  printf("POSSIBLE\n%d %d\n", s1, s2);
  for (int i = (1), _ed = (n); i <= _ed; ++i) printf("%d", c[i]);
  puts("");
  return 0;
}
