#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 153;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 1e5 + 100;
int n;
int l[N], r[N];
vector<int> g[N];
int c[N];
bool paint(int v, int x) {
  if (c[v] != -1) {
    if (c[v] != x) return false;
    return true;
  }
  c[v] = x;
  for (int u : g[v]) {
    int nx = x ^ 1;
    if (!paint(u, nx)) return false;
  }
  return true;
}
void solve(int a, int b) {
  0;
  if (a < 0 || b < 0) return;
  memset(c, -1, sizeof c);
  for (int i = 1; i <= n; i++) {
    bool oka = (l[i] <= a && a <= r[i]);
    bool okb = (l[i] <= b && b <= r[i]);
    if (!oka && !okb) {
      return;
    }
    if (!oka) {
      if (!paint(i, 1)) return;
    } else if (!okb) {
      assert(oka);
      if (!paint(i, 0)) return;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] == -1) {
      if (!paint(i, 0)) return;
    }
  }
  puts("POSSIBLE");
  printf("%d %d\n", a, b);
  for (int i = 1; i <= n; i++) printf("%d", c[i] + 1);
  puts("");
  exit(0);
}
int main() {
  int tL = read();
  int tR = read();
  n = read();
  int m = read();
  int a = inf, b = -inf;
  for (int i = 1; i <= n; i++) {
    l[i] = read();
    r[i] = read();
    umin(a, r[i]);
    umax(b, l[i]);
  }
  for (int i = 1; i <= m; i++) {
    int u = read();
    int v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  if (a > b) {
    if (b + b < tR) {
      a = b;
    } else if (a + a > tL) {
      b = a;
    }
  }
  if (a + b > tR) {
    a -= (a + b) - tR;
  } else if (a + b < tL) {
    b += tL - (a + b);
  }
  solve(a, b);
  puts("IMPOSSIBLE");
  return 0;
}
