#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool uax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MAXN = 110000;
int l[MAXN], r[MAXN];
vector<int> e[MAXN];
int vis[MAXN], c[MAXN];
bool dfs(int v, int col, pair<int, int> &l0, pair<int, int> &l1,
         vector<int> &v0, vector<int> &v1) {
  if (vis[v]) return c[v] == col;
  vis[v] = 1;
  c[v] = col;
  uax((col ? l1 : l0).first, l[v]);
  uin((col ? l1 : l0).second, r[v]);
  (col ? v1 : v0).push_back(v);
  for (int u : e[v]) {
    if (!dfs(u, col ^ 1, l0, l1, v0, v1)) return false;
  }
  return true;
}
struct TEvent {
  int x, type;
  int id, w;
  pair<int, int> p;
  TEvent(int x = 0, int type = 0, int id = 0, int w = 0,
         pair<int, int> p = make_pair(0, 0))
      : x(x), type(type), id(id), w(w), p(p) {}
  bool operator<(const TEvent &ev) const {
    if (x != ev.x) return x < ev.x;
    return type > ev.type;
  }
};
const int MAXT = 110000;
int t[MAXT];
void ins_seg(int l, int r, pair<int, int> p, int id, int w,
             vector<TEvent> &evs) {
  assert(r >= l);
  if (l == r) return;
  evs.push_back(TEvent(l, 0, id, w, p));
  evs.push_back(TEvent(r, 1, id, w, p));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int lt, rt;
  cin >> lt >> rt;
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < (int)(N); ++i) cin >> l[i] >> r[i];
  for (int i = 0; i < (int)(M); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  vector<vector<int> > vs[2];
  vector<pair<int, int> > l[2];
  bool ok = true;
  vector<TEvent> evs;
  int K = 0;
  for (int i = 0; i < (int)(N); ++i) {
    if (vis[i]) continue;
    pair<int, int> l0 = make_pair(0, (int)1e9);
    pair<int, int> l1 = make_pair(0, (int)1e9);
    vector<int> v0, v1;
    ok &= dfs(i, 0, l0, l1, v0, v1);
    if (l0.first > l1.first) swap(l0, l1), swap(v0, v1);
    ok &= l0.first <= l0.second;
    ok &= l1.first <= l1.second;
    if (!ok) break;
    vs[0].push_back(v0);
    vs[1].push_back(v1);
    l[0].push_back(l0);
    l[1].push_back(l1);
    if (l0.second >= l1.first) {
      ins_seg(l0.first, l1.first, l1, K, 0, evs);
      if (l0.second > l1.second) {
        ins_seg(l1.first, l1.second + 1, l0, K, 1, evs);
        ins_seg(l1.second + 1, l0.second + 1, l1, K, 0, evs);
      } else {
        ins_seg(l1.first, l0.second + 1, make_pair(l0.first, l1.second), K, 2,
                evs);
        ins_seg(l0.second + 1, l1.second + 1, l0, K, 1, evs);
      }
    } else {
      ins_seg(l0.first, l0.second + 1, l1, K, 0, evs);
      ins_seg(l1.first, l1.second + 1, l0, K, 1, evs);
    }
    ++K;
  }
  if (!ok) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  sort((evs).begin(), (evs).end());
  multiset<int> ls, rs;
  ls.insert(0);
  rs.insert(1e9);
  int i = 0;
  int A = -1, B = -1;
  ok = false;
  while (i < evs.size()) {
    int x = evs[i].x;
    int j = i;
    while (j < evs.size() && evs[j].x == x) ++j;
    for (int k = i; k < j; ++k) {
      int type = evs[k].type, id = evs[k].id, w = evs[k].w;
      pair<int, int> p = evs[k].p;
      if (type == 0) {
        t[id] = w;
        ls.insert(p.first);
        rs.insert(p.second);
      } else {
        ls.erase(ls.find(p.first));
        rs.erase(rs.find(p.second));
      }
    }
    int nx = (j == evs.size() ? (int)1e9 + 1 : evs[j].x) - 1;
    int lx = *ls.rbegin();
    int rx = *rs.begin();
    i = j;
    if (ls.size() == K + 1 && lx <= rx && max(lx + x, lt) <= min(rx + nx, rt)) {
      if (x + lx >= lt)
        A = x, B = lx;
      else if (x + rx >= lt)
        A = x, B = lt - x;
      else
        A = lt - rx, B = rx;
    } else
      continue;
    for (int k = 0; k < (int)(N); ++k) {
      if (t[k] == 2) {
        t[k] = (l[0][k].first <= B && B <= l[0][k].second ? 1 : 0);
      }
    }
    ok = true;
    break;
  }
  if (!ok) {
    cout << "IMPOSSIBLE\n";
  } else {
    cout << "POSSIBLE\n";
    cout << A << ' ' << B << '\n';
    vector<int> ans(N);
    for (int i = 0; i < (int)(K); ++i)
      for (int j = 0; j < (int)(2); ++j)
        for (int x : vs[j][i]) ans[x] = j ^ t[i];
    for (int i = 0; i < (int)(N); ++i) cout << ans[i] + 1;
    cout << '\n';
  }
  return 0;
}
