#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int col[N], l[N], r[N], fl = 1;
vector<int> to[N];
void dfs(int x) {
  for (int i = 0; i < to[x].size(); i++) {
    int y = to[x][i];
    if (col[x] == col[y]) fl = 0;
    if (!col[y]) col[y] = 3 - col[x], dfs(y);
  }
}
int main() {
  int t, T, n, m;
  scanf("%d%d%d%d", &t, &T, &n, &m);
  int n1 = 0x7f7f7f7f, n2 = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &l[i], &r[i]);
    n1 = min(n1, r[i]);
    n2 = max(n2, l[i]);
  }
  if (n1 + n2 < t) n2 = t - n1;
  if (n1 + n2 > T) n1 = T - n2;
  if (n1 < 0 || n2 < 0) return puts("IMPOSSIBLE") * 0;
  for (int i = 1; i <= n; i++) {
    int p1 = l[i] <= n1 && n1 <= r[i], p2 = l[i] <= n2 && n2 <= r[i];
    if (!p1 && !p2) return puts("IMPOSSIBLE") * 0;
    if (!p1) col[i] = 2;
    if (!p2) col[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    to[x].push_back(y);
    to[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (col[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (!col[i]) col[i] = 1, dfs(i);
  if (!fl) return puts("IMPOSSIBLE") * 0;
  puts("POSSIBLE");
  printf("%d %d\n", n1, n2);
  for (int i = 1; i <= n; i++) printf("%d", col[i]);
}
