#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp& x) {
  x = 0;
  char tmp;
  bool key = 0;
  for (tmp = getchar(); !isdigit(tmp); tmp = getchar()) key = (tmp == '-');
  for (; isdigit(tmp); tmp = getchar()) x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x, tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x, tp y) {
  x = x < y ? y : x;
}
const int N = 200010, M = N * 15, SZ = N * 5;
int n, m, t, T, lp[N], rp[N], id[N][2], rec[2][N][2], val[2][N], sz[2], cnt;
struct data {
  int tp, from, v;
  bool operator<(const data& a) const { return v < a.v; }
} dat[N];
int dcnt;
struct edge {
  int la, b;
} con[M];
int tot, first[SZ];
void add_edge(int from, int to) {
  con[++tot] = (edge){first[from], to};
  first[from] = tot;
}
int dfn[SZ], low[SZ], sta[SZ], top, col[SZ], ccnt;
void dfs(int pos) {
  sta[dfn[pos] = low[pos] = ++top] = pos;
  for (int i = first[pos]; i; i = con[i].la) {
    if (col[con[i].b]) continue;
    if (!dfn[con[i].b]) dfs(con[i].b);
    low[pos] = min(low[pos], low[con[i].b]);
  }
  if (low[pos] >= dfn[pos]) {
    ++ccnt;
    while (top >= dfn[pos]) col[sta[top--]] = ccnt;
  }
}
void tarjan() {
  for (int i = (1); i <= (cnt); ++i)
    if (!dfn[i]) dfs(i);
}
void solve(int v) {
  dcnt = 0;
  for (int i = (1); i <= (n); ++i) {
    dat[++dcnt] = (data){0, i, rp[i]};
    dat[++dcnt] = (data){1, i, lp[i] - 1};
  }
  vector<int> vec;
  for (int i = (1); i <= (dcnt); ++i) vec.push_back(dat[i].v);
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  sz[v] = (int)vec.size();
  for (int i = (1); i <= (sz[v]); ++i) val[v][i] = vec[i - 1];
  for (int i = (1); i <= (sz[v]); ++i)
    for (int a = (0); a <= (1); ++a) rec[v][i][a] = ++cnt;
  for (int i = (1); i <= (sz[v] - 1); ++i) {
    add_edge(rec[v][i][0], rec[v][i + 1][0]);
    add_edge(rec[v][i + 1][1], rec[v][i][1]);
  }
  for (int i = (1); i <= (dcnt); ++i) {
    int tmp = lower_bound(val[v] + 1, val[v] + sz[v] + 1, dat[i].v) - val[v];
    if (dat[i].tp == 0) {
      add_edge(id[dat[i].from][v], rec[v][tmp][0]);
      add_edge(rec[v][tmp][1], id[dat[i].from][v ^ 1]);
    } else {
      add_edge(id[dat[i].from][v], rec[v][tmp][1]);
      add_edge(rec[v][tmp][0], id[dat[i].from][v ^ 1]);
    }
  }
}
void fail() {
  puts("IMPOSSIBLE");
  exit(0);
}
int main() {
  int x, y;
  read(t), read(T);
  read(n), read(m);
  for (int i = (1); i <= (n); ++i) read(lp[i]), read(rp[i]);
  for (int i = (1); i <= (n); ++i)
    for (int j = (0); j <= (1); ++j) id[i][j] = ++cnt;
  for (int a = (0); a <= (1); ++a) solve(a);
  for (int a = (0); a <= (1); ++a) {
    for (int i = (1); i <= (sz[a]); ++i) {
      int tmp = upper_bound(val[a ^ 1] + 1, val[a ^ 1] + sz[a ^ 1] + 1,
                            t - val[a][i] - 1) -
                val[a ^ 1] - 1;
      if (tmp) add_edge(rec[a][i][0], rec[a ^ 1][tmp][1]);
      tmp = lower_bound(val[a ^ 1] + 1, val[a ^ 1] + sz[a ^ 1] + 1,
                        T - val[a][i] - 1) -
            val[a ^ 1];
      if (tmp <= sz[a ^ 1]) add_edge(rec[a][i][1], rec[a ^ 1][tmp][0]);
    }
  }
  for (int i = (1); i <= (m); ++i) {
    read(x), read(y);
    add_edge(id[x][0], id[y][1]);
    add_edge(id[x][1], id[y][0]);
    add_edge(id[y][0], id[x][1]);
    add_edge(id[y][1], id[x][0]);
  }
  tarjan();
  for (int i = (1); i <= (n); ++i) {
    if (col[id[i][0]] == col[id[i][1]]) fail();
  }
  int l1 = 0, r1 = T, l2 = 0, r2 = T;
  for (int a = (0); a <= (1); ++a) {
    for (int i = (1); i <= (sz[a]); ++i) {
      if (col[rec[a][i][0]] == col[rec[a][i][1]]) fail();
      if (col[rec[a][i][0]] < col[rec[a][i][1]]) {
        if (a == 0)
          r1 = min(r1, val[a][i]);
        else
          r2 = min(r2, val[a][i]);
      } else {
        if (a == 0)
          l1 = max(l1, val[a][i] + 1);
        else
          l2 = max(l2, val[a][i] + 1);
      }
    }
  }
  if (l1 > r1 || l2 > r2) fail();
  int n1 = r1, n2 = r2;
  assert(n1 + n2 >= t);
  n1 -= max(0, min(r1 - l1, n1 + n2 - T));
  n2 -= max(0, min(r2 - l2, n1 + n2 - T));
  assert(n1 + n2 <= T);
  puts("POSSIBLE");
  printf("%d %d\n", n1, n2);
  for (int i = (1); i <= (n); ++i) {
    if (col[id[i][0]] < col[id[i][1]])
      putchar('1');
    else
      putchar('2');
  }
  puts("");
  return 0;
}
