#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, t = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') t = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * t;
}
const int N = 1e5 + 5;
int tL, tR, n, m, n1, n2, flag;
int c[N], L[N], R[N];
vector<int> G[N];
void Return() { puts("IMPOSSIBLE"), exit(0); }
void DFS(int x, int t) {
  for (auto y : G[x]) {
    if (!c[y])
      c[y] = 3 - t, DFS(y, 3 - t);
    else if (c[y] != 3 - t)
      flag = 1;
  }
}
int main() {
  tL = read(), tR = read(), n = read(), m = read();
  n1 = 1e9, n2 = 0;
  for (int i = 1; i <= n; i++) {
    L[i] = read(), R[i] = read();
    n1 = min(n1, R[i]), n2 = max(n2, L[i]);
  }
  if (n1 + n2 < tL) n2 = tL - n1;
  if (n1 + n2 > tR) n1 = tR - n2;
  if (n1 < 0 || n2 < 0) Return();
  for (int i = 1; i <= n; i++) {
    int a = (L[i] <= n1 && n1 <= R[i]), b = (L[i] <= n2 && n2 <= R[i]);
    if (!a && !b) Return();
    if (!a) c[i] = 2;
    if (!b) c[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y), G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (c[i]) {
      flag = 0, DFS(i, c[i]);
      if (flag) Return();
    }
  for (int i = 1; i <= n; i++)
    if (!c[i]) {
      flag = 0, DFS(i, c[i] = 1);
      if (flag) Return();
    }
  puts("POSSIBLE");
  cout << n1 << ' ' << n2 << '\n';
  for (int i = 1; i <= n; i++) cout << c[i];
  return 0;
}
