#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
const int maxn = 1e5 + 233;
void GG() {
  puts("IMPOSSIBLE");
  exit(0);
}
vector<int> edge[maxn];
int l[maxn], r[maxn], c[maxn];
int X, Y, t, T, n, m;
void dfs(int u, int col) {
  if (c[u]) {
    if (c[u] != col) GG();
    return;
  }
  c[u] = col;
  for (auto v : edge[u]) {
    dfs(v, 3 - col);
  }
}
int main() {
  t = read(), T = read();
  n = read(), m = read();
  int X = 1e9, Y = 0;
  for (register int i = (1); i <= int(n); ++i) {
    l[i] = read(), r[i] = read();
    X = min(X, r[i]);
    Y = max(Y, l[i]);
  }
  for (register int i = (1); i <= int(n); ++i) edge[i].clear();
  for (register int i = (1); i <= int(m); ++i) {
    int a = read(), b = read();
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if (X + Y < t)
    Y = t - X;
  else if (X + Y > T)
    X = T - Y;
  if (X < 0 || Y < 0) GG();
  memset(c, 0, sizeof(c));
  for (register int i = (1); i <= int(n); ++i) {
    if (l[i] <= X && X <= r[i]) {
      if (l[i] <= Y && Y <= r[i]) {
        int wzp = 1, akking = 1;
        assert(wzp == akking);
      } else {
        dfs(i, 1);
      }
    } else if (l[i] <= Y && Y <= r[i]) {
      dfs(i, 2);
    } else {
      GG();
    }
  }
  for (register int i = (1); i <= int(n); ++i)
    if (!c[i]) dfs(i, 1);
  puts("POSSIBLE");
  write(X), putchar(' '), writeln(Y);
  for (register int i = (1); i <= int(n); ++i) {
    write(c[i]);
  }
  return 0;
}
