#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool checkMax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T, typename... Args>
inline void checkMax(T &a, const Args... arg) {
  checkMax(a, max(arg...));
}
template <class T>
inline bool checkMin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename... Args>
inline void checkMin(T &a, const Args... arg) {
  checkMin(a, min(arg...));
}
const int INF = 0x3f3f3f3f;
const long long llINF = 1e18;
const int MAXN = 1e5 + 5;
int n, m, len, L, R = INF, T, t;
int head[MAXN], col[MAXN], l[MAXN], r[MAXN];
struct Edge {
  int to, next;
} e[MAXN << 1];
void add_edge(int u, int v) {
  e[++len] = (Edge){v, head[u]};
  head[u] = len;
}
int dfs(int u) {
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].to;
    if (!col[v]) {
      col[v] = 3 - col[u];
      if (!dfs(v)) return 0;
    } else if (col[v] == col[u])
      return 0;
  }
  return 1;
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d%d%d", &t, &T, &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    checkMax(L, l[i]);
    checkMin(R, r[i]);
  }
  if (L + R < t) L = t - R;
  if (L + R > T) R = T - L;
  if (L < 0 || R < 0) {
    puts("IMPOSSIBLE");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    bool a = (L >= l[i] && L <= r[i]), b = (R >= l[i] && R <= r[i]);
    if (!a && !b) {
      puts("IMPOSSIBLE");
      return 0;
    }
    if (a && !b) col[i] = 1;
    if (b && !a) col[i] = 2;
  }
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  for (int i = 1; i <= n; i++) {
    if (col[i] && !dfs(i)) {
      puts("IMPOSSIBLE");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!col[i]) {
      col[i] = 1;
      if (!dfs(i)) {
        puts("IMPOSSIBLE");
        return 0;
      }
    }
  }
  printf("POSSIBLE\n%d %d\n", L, R);
  for (int i = 1; i <= n; i++) putchar('0' + col[i]);
  return 0;
}
