#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
void et() {
  puts("IMPOSSIBLE");
  exit(0);
}
struct uz {
  int id, x, l, r;
  uz() {}
  uz(int x, int id, int l, int r) : x(x), id(id), l(l), r(r) {}
  bool operator<(const uz &o) const {
    if (x == o.x) return id < o.id;
    return x < o.x;
  }
};
vector<uz> vt;
int t, T, l[100105], r[100105], cnt, belong[100105];
vector<int> mp[100105];
int vis[100105];
pair<int, int> P[2], cp[100105][2];
void dfs(int x, int w) {
  P[w - 1].first = max(P[w - 1].first, l[x]);
  P[w - 1].second = min(P[w - 1].second, r[x]);
  vis[x] = w;
  belong[x] = cnt;
  for (int c : mp[x]) {
    if (vis[c] == 0)
      dfs(c, 3 - w);
    else if (vis[c] != 3 - w)
      et();
  }
}
multiset<int> ls, rs;
void pp(int A, int B) {
  puts("POSSIBLE");
  printf("%d %d\n", A, B);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    cnt = belong[i];
    int j = vis[i] - 1;
    for (int(j) = 0; (j) < (int)(2); (j)++) P[j] = cp[cnt][j];
    if (P[0].first <= A && A <= P[0].second &&
        P[1].first <= B & B <= P[1].second) {
      k = j == 0 ? 1 : 2;
    } else {
      k = j == 1 ? 1 : 2;
    }
    printf("%d", k);
  }
  puts("");
  exit(0);
}
void cal() {
  int i = 0;
  while (i < vt.size()) {
    int x = vt[i].x, j = i;
    for (; j < vt.size() && vt[j].x == x; j++) {
      if (vt[j].id < 0) {
        ls.insert(vt[j].l);
        rs.insert(vt[j].r);
      } else {
        ls.erase(ls.find(vt[j].l));
        rs.erase(rs.find(vt[j].r));
      }
    }
    int nx = j == vt.size() ? (1 << 30) : vt[j].x;
    nx--;
    i = j;
    if (ls.size() == cnt) {
      int lx = *ls.rbegin(), rx = *rs.begin();
      if (lx <= rx && max(lx + x, t) <= min(T, nx + rx)) {
        int SS = max(lx + x, t), A, B;
        if (SS - x <= rx) {
          A = x;
          B = SS - x;
        } else {
          A = SS - rx;
          B = rx;
        }
        pp(A, B);
      }
    }
  }
  et();
}
int main() {
  scanf("%d%d", &t, &T);
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d%d", l + i, r + i);
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    mp[u].push_back(v);
    mp[v].push_back(u);
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (vis[i] == 0) {
      cnt++;
      for (int(j) = 0; (j) < (int)(2); (j)++) P[j] = {0, (1 << 30)};
      dfs(i, 1);
      for (int(j) = 0; (j) < (int)(2); (j)++)
        if (P[j].first > P[j].second) et();
      for (int(j) = 0; (j) < (int)(2); (j)++) cp[cnt][j] = P[j];
      if (P[0].first > P[1].first) swap(P[0], P[1]);
      if (P[0].second < P[1].first) {
        vt.push_back(uz(P[0].first, -cnt, P[1].first, P[1].second));
        vt.push_back(uz(P[0].second + 1, cnt, P[1].first, P[1].second));
        vt.push_back(uz(P[1].first, -cnt, P[0].first, P[0].second));
        vt.push_back(uz(P[1].second + 1, cnt, P[0].first, P[0].second));
      } else {
        vt.push_back(uz(P[0].first, -cnt, P[1].first, P[1].second));
        vt.push_back(uz(P[1].first, cnt, P[1].first, P[1].second));
        if (P[0].second > P[1].second) {
          vt.push_back(uz(P[1].first, -cnt, P[0].first, P[0].second));
          vt.push_back(uz(P[1].second + 1, cnt, P[0].first, P[0].second));
          vt.push_back(uz(P[1].second + 1, -cnt, P[1].first, P[1].second));
          vt.push_back(uz(P[0].second + 1, cnt, P[1].first, P[1].second));
        } else {
          vt.push_back(uz(P[1].first, -cnt, P[0].first, P[1].second));
          vt.push_back(uz(P[0].second + 1, cnt, P[0].first, P[1].second));
          vt.push_back(uz(P[0].second + 1, -cnt, P[0].first, P[0].second));
          vt.push_back(uz(P[1].second + 1, cnt, P[0].first, P[0].second));
        }
      }
    }
  sort(vt.begin(), vt.end());
  cal();
  return 0;
}
