#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int col[1900010], n, m, flag;
int L, R, l[1900010], r[1900010], bel[1900010], vis[1900010];
vector<int> G[1900010];
void dfs(int now) {
  vis[now] = 1;
  for (int to : G[now]) {
    if (!col[to])
      col[to] = 3 - col[now], dfs(to);
    else if (col[to] == col[now]) {
      puts("IMPOSSIBLE");
      exit(0);
    }
  }
}
int main() {
  L = read(), R = read();
  n = read(), m = read();
  int p = -1e9, q = 1e9;
  for (register int i = 1; i <= n; i++) {
    l[i] = read(), r[i] = read();
    p = max(p, l[i]);
    q = min(q, r[i]);
  }
  if (p + q < L) p = L - q;
  if (p + q > R) q = R - p;
  if (p < 0 || q < 0) {
    puts("IMPOSSIBLE");
    return 0;
  }
  for (register int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
    G[y].push_back(x);
  }
  flag = 0;
  for (register int i = 1; i <= n; i++) {
    if (l[i] <= p && r[i] >= p && l[i] <= q && r[i] >= q)
      continue;
    else if (l[i] <= p && r[i] >= p) {
      col[i] = 1;
    } else if (l[i] <= q && r[i] >= q) {
      col[i] = 2;
    } else {
      flag = 1;
    }
  }
  if (flag) {
    puts("IMPOSSIBLE");
    return 0;
  }
  for (register int i = 1; i <= n; i++)
    if (!vis[i] && col[i]) dfs(i);
  for (register int i = 1; i <= n; i++) {
    if (!vis[i] && !col[i]) {
      col[i] = 1;
      dfs(i);
    }
  }
  puts("POSSIBLE");
  printf("%d %d\n", p, q);
  for (register int i = 1; i <= n; i++) printf("%d", col[i]);
  puts("");
  return 0;
}
