#include <bits/stdc++.h>
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 100000;
int col[N], l[N], r[N];
vector<int> e[N];
void bipartite(int v, int c) {
  if (c == col[v]) return;
  if (3 - c == col[v]) throw 0;
  col[v] = c;
  for (auto u : e[v]) bipartite(u, 3 - c);
}
void f(int N, int M, int x, int y) {
  if (y < 0) throw 0;
  while (M--) {
    int v = ri() - 1, u = ri() - 1;
    e[v].push_back(u);
    e[u].push_back(v);
  }
  for (int i = (0); i < (N); i++) {
    if ((!(l[i] <= x && x <= r[i]))) {
      if ((!(l[i] <= y && y <= r[i]))) throw 0;
      bipartite(i, 2);
    } else if ((!(l[i] <= y && y <= r[i])))
      bipartite(i, 1);
  }
  for (int i = (0); i < (N); i++)
    if (!col[i]) bipartite(i, 1);
}
int main() {
  int t = ri(), T = ri(), N = ri(), M = ri(), x = 0, y = T;
  for (int i = (0); i < (N); i++) {
    l[i] = ri();
    r[i] = ri();
    x = max(x, l[i]);
    y = min(y, r[i]);
  }
  if (x + y < t)
    x = t - y;
  else if (x + y > T)
    y = T - x;
  try {
    f(N, M, x, y);
    printf("POSSIBLE\n%d %d\n", x, y);
    for (int i = (0); i < (N); i++) printf("%d", col[i]);
    puts("");
  } catch (...) {
    puts("IMPOSSIBLE");
  }
}
