#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int l[maxn], e, sz, tot, n1, n2, f = 0;
int l_n1, r_n1;
int n, m, t, T, t_l[maxn], t_r[maxn], col[maxn], vis[maxn];
struct Edge {
  int v, x;
} E[maxn << 1];
inline void addEdge(int u, int v) { E[e].v = v, E[e].x = l[u], l[u] = e++; }
int bid[maxn], b_l[2][maxn], b_r[2][maxn], rev[maxn];
vector<pair<int, int> > del[maxn * 2], add[maxn * 2];
vector<int> cur_block, vec;
;
int getIndex(int x) {
  return int(lower_bound(vec.begin(), vec.end(), x) - vec.begin() + 1);
}
void dfs(int u) {
  cur_block.push_back(u);
  vis[u] = 1;
  for (int p = l[u]; p >= 0; p = E[p].x) {
    int v = E[p].v;
    if (!vis[v]) {
      col[v] = col[u] ^ 1;
      dfs(v);
    } else if (col[u] == col[v]) {
      puts("IMPOSSIBLE");
      exit(0);
    }
  }
}
void addSeg(int l, int r, pair<int, int> p) {
  if (l > r) return;
  add[l].push_back(p);
  del[r + 1].push_back(p);
}
int cross(int l1, int r1, int l2, int r2) { return max(l1, l2) <= min(r1, r2); }
int main() {
  scanf("%d%d", &t, &T);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &t_l[i], &t_r[i]);
    vec.push_back(t_l[i]);
    vec.push_back(t_r[i] + 1);
  }
  memset(l, -1, sizeof(l));
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addEdge(u, v), addEdge(v, u);
  }
  vec.push_back(0), vec.push_back(int(1e9 + 1));
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  sz = int(vec.size());
  for (int i = 1; i <= n; i++) {
    t_l[i] = getIndex(t_l[i]);
    t_r[i] = getIndex(t_r[i] + 1) - 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ++tot;
      cur_block.clear();
      dfs(i);
      int l[2], r[2];
      l[0] = l[1] = 1, r[0] = r[1] = sz - 1;
      for (int j = 0; j < cur_block.size(); j++) {
        int u = cur_block[j];
        l[col[u]] = max(l[col[u]], t_l[u]);
        r[col[u]] = min(r[col[u]], t_r[u]);
        bid[u] = tot;
      }
      if (l[0] > l[1]) {
        swap(l[0], l[1]);
        swap(r[0], r[1]);
        for (int j = 0; j < cur_block.size(); j++) {
          int u = cur_block[j];
          col[u] ^= 1;
        }
      }
      b_l[0][tot] = l[0], b_l[1][tot] = l[1];
      b_r[0][tot] = r[0], b_r[1][tot] = r[1];
      if (max(l[0], l[1]) <= min(r[0], r[1])) {
        if (r[0] >= r[1]) {
          addSeg(1, l[0] - 1, pair<int, int>(1, 0));
          addSeg(l[0], l[1] - 1, pair<int, int>(l[1], r[1]));
          addSeg(l[1], r[1], pair<int, int>(l[0], r[0]));
          addSeg(r[1] + 1, r[0], pair<int, int>(l[1], r[1]));
          addSeg(r[0] + 1, sz - 1, pair<int, int>(1, 0));
        } else {
          addSeg(1, l[0] - 1, pair<int, int>(1, 0));
          addSeg(l[0], l[1] - 1, pair<int, int>(l[1], r[1]));
          addSeg(l[1], r[0], pair<int, int>(l[0], r[1]));
          addSeg(r[0] + 1, r[1], pair<int, int>(l[0], r[0]));
          addSeg(r[1] + 1, sz - 1, pair<int, int>(1, 0));
        }
      } else {
        addSeg(1, l[0] - 1, pair<int, int>(1, 0));
        addSeg(l[0], r[0], pair<int, int>(l[1], r[1]));
        addSeg(r[0] + 1, l[1] - 1, pair<int, int>(1, 0));
        addSeg(l[1], r[1], pair<int, int>(l[0], r[0]));
        addSeg(r[1] + 1, sz - 1, pair<int, int>(1, 0));
      }
    }
  }
  priority_queue<int, vector<int>, less<int> > ql, dl;
  priority_queue<int, vector<int>, greater<int> > qr, dr;
  ql.push(1), qr.push(sz - 1);
  for (int i = 1; i < sz; i++) {
    for (int j = 0; j < add[i].size(); j++) {
      ql.push(add[i][j].first);
      qr.push(add[i][j].second);
    }
    for (int j = 0; j < del[i].size(); j++) {
      dl.push(del[i][j].first);
      dr.push(del[i][j].second);
    }
    while (!dl.empty() && ql.top() == dl.top()) ql.pop(), dl.pop();
    while (!dr.empty() && qr.top() == dr.top()) qr.pop(), dr.pop();
    if (ql.top() <= qr.top()) {
      int ln2 = vec[ql.top() - 1], rn2 = vec[qr.top()] - 1;
      int ln1 = vec[i - 1], rn1 = vec[i] - 1;
      if (cross(ln1 + ln2, rn1 + rn2, t, T)) {
        n1 = ln1, n2 = ln2;
        int cur_n = n1 + n2;
        int v1 = min(max(0, t - cur_n), rn1 - n1);
        n1 += v1, cur_n += v1;
        int v2 = min(max(0, t - cur_n), rn2 - n2);
        n2 += v2, cur_n += v2;
        f = 1;
        break;
      }
    }
  }
  for (int i = 1; i <= tot; i++) {
    b_l[0][i] = vec[b_l[0][i] - 1];
    b_l[1][i] = vec[b_l[1][i] - 1];
    b_r[0][i] = vec[b_r[0][i]] - 1;
    b_r[1][i] = vec[b_r[1][i]] - 1;
  }
  if (!f)
    puts("IMPOSSIBLE");
  else {
    puts("POSSIBLE");
    printf("%d %d\n", n1, n2);
    for (int i = 1; i <= tot; i++) {
      if (n1 >= b_l[0][i] && n1 <= b_r[0][i] && n2 >= b_l[1][i] &&
          n2 <= b_r[1][i]) {
        rev[i] = 0;
      } else
        rev[i] = 1;
    }
    for (int i = 1; i <= n; i++) putchar('1' + (rev[bid[i]] ^ col[i]));
    puts("");
  }
  return 0;
}
