#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INF_LL = 1000000000000000000LL;
const double pi = acos(-1.0);
template <class T>
T& smin(T& a, const T& b) {
  if (a > b) a = b;
  return a;
}
template <class T>
T& smax(T& a, const T& b) {
  if (a < b) a = b;
  return a;
}
template <class T>
T gcd(T a, T b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  while (a && b) {
    if (a >= b)
      a %= b;
    else
      b %= a;
  }
  return a + b;
}
template <class T>
T sqr(const T& a) {
  return a * a;
}
template <typename Iterator>
void print(const char* fmt, Iterator begin, Iterator end,
           const char* separator = " ") {
  for (Iterator it = begin; it != end; ++it) {
    if (it != begin) printf("%s", separator);
    printf(fmt, *it);
  }
  printf("\n");
}
template <class T>
class SegmentTree {
 public:
  void init(int n_, const T& v = T()) {
    n = n_;
    t = vector<T>(2 * n, v);
  }
  T& operator[](int p) { return t[p + n]; }
  const T& operator[](int p) const { return t[p + n]; }
  void push() {
    for (int i(1), _b(n); i < _b; ++i) {
      t[i << 1].inc(t[i]);
      t[i << 1 | 1].inc(t[i]);
      t[i] = T();
    }
  }
  void inc(int l, int r, const T& delta) {
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) t[l++].inc(delta);
      if (r & 1) t[--r].inc(delta);
    }
  }
  T query(int p) const {
    T res;
    for (p += n; p > 0; p >>= 1) res.inc(t[p]);
    return res;
  }

 private:
  int n;
  vector<T> t;
};
struct Vmin {
  int v;
  Vmin(int v = INF) : v(v) {}
  void inc(const Vmin& b) { smin(v, b.v); }
  friend Vmin sum(const Vmin& a, const Vmin& b) { return min(a.v, b.v); }
};
struct Vmax {
  int v;
  Vmax(int v = -INF) : v(v) {}
  void inc(const Vmax& b) { smax(v, b.v); }
  friend Vmax sum(const Vmax& a, const Vmax& b) { return max(a.v, b.v); }
};
const int N = 200011;
int t, T;
int n, m, k;
pair<int, int> b[N];
vector<int> e[N];
map<int, int> mg;
int g[N];
pair<int, int> o[N];
void upd(pair<int, int>& a, const pair<int, int>& b) {
  smax(a.first, b.first);
  smin(a.second, b.second);
}
vector<pair<int, int> > q;
int p[N], r[N];
pair<int, int> f[N];
SegmentTree<Vmin> tmin;
SegmentTree<Vmax> tmax;
void updt(int l, int r, pair<int, int> v) {
  tmin.inc(l, r, v.second);
  tmax.inc(l, r, v.first);
}
void impsy() {
  printf("IMPOSSIBLE\n");
  exit(0);
}
int main() {
  cin.tie(NULL);
  scanf("%d%d", &t, &T);
  scanf("%d%d", &n, &m);
  for (int i(0), _b(n); i < _b; ++i) {
    scanf("%d%d", &b[i].first, &b[i].second);
    if (b[i].first > T) impsy();
    smin(b[i].second, T);
  }
  for (int i(0), _b(n); i < _b; ++i) g[i] = b[i].first;
  for (int i(0), _b(n); i < _b; ++i) g[n + i] = b[i].second;
  g[2 * n] = 0;
  sort(g, g + 2 * n + 1);
  k = unique(g, g + 2 * n + 1) - g;
  for (int i(0), _b(k); i < _b; ++i) mg[g[i]] = i;
  for (int i(0), _b(k); i < _b; ++i) o[i] = pair<int, int>(0, T);
  for (int i(0), _b(m); i < _b; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  q.clear();
  for (int i(0), _b(n); i < _b; ++i)
    if (e[i].empty()) q.push_back(pair<int, int>(b[i].second, i));
  sort((q).begin(), (q).end());
  int u = 0;
  pair<int, int> s(0, T);
  for (int i(0), _b(k); i < _b; ++i) {
    upd(o[i], s);
    while (u < int((q).size()) && q[u].first == g[i])
      upd(s, b[q[u].second]), ++u;
  }
  q.clear();
  for (int i(0), _b(n); i < _b; ++i)
    if (e[i].empty()) q.push_back(pair<int, int>(b[i].first, i));
  sort((q).begin(), (q).end());
  u = int((q).size()) - 1;
  s = pair<int, int>(0, T);
  for (int i(k - 1), _b(0); i >= _b; --i) {
    upd(o[i], s);
    while (u >= 0 && q[u].first == g[i]) upd(s, b[q[u].second]), --u;
  }
  tmin.init(k, T);
  tmax.init(k, 0);
  fill(p, p + n, -1);
  int kp = 0;
  for (int i(0), _b(n); i < _b; ++i)
    if (!e[i].empty() && p[i] == -1) {
      p[i] = kp;
      f[kp] = f[kp ^ 1] = pair<int, int>(0, T);
      vector<int> q(1, i);
      for (int qa = 0; qa < int((q).size()); ++qa) {
        int i = q[qa];
        upd(f[p[i]], b[i]);
        for (int u(0), _b(int((e[i]).size())); u < _b; ++u) {
          int j = e[i][u];
          if (p[j] == -1) {
            p[j] = p[i] ^ 1;
            q.push_back(j);
          } else if (p[j] == p[i])
            impsy();
        }
      }
      pair<int, int> gf[2];
      for (int a(kp), _b(kp + 2); a < _b; ++a)
        if (f[a].first > f[a].second) impsy();
      for (int a(0), _b(2); a < _b; ++a)
        gf[a] = pair<int, int>(mg[f[kp ^ a].first], mg[f[kp ^ a].second]);
      tmin.inc(0, min(gf[0].first, gf[1].first), -1);
      tmin.inc(max(gf[0].second, gf[1].second) + 1, k, -1);
      if (f[kp].first <= f[kp ^ 1].second && f[kp ^ 1].first <= f[kp].second) {
        if (f[kp].first <= f[kp ^ 1].first)
          updt(gf[0].first, gf[1].first, f[kp ^ 1]);
        else
          updt(gf[1].first, gf[0].first, f[kp]);
        if (f[kp].second <= f[kp ^ 1].second)
          updt(gf[0].second, gf[1].second, f[kp]);
        else
          updt(gf[1].second, gf[0].second, f[kp ^ 1]);
        updt(max(gf[0].first, gf[1].first), min(gf[0].second, gf[1].second) + 1,
             pair<int, int>(min(f[kp].first, f[kp ^ 1].first),
                            max(f[kp].second, f[kp ^ 1].second)));
      } else {
        for (int a(0), _b(2); a < _b; ++a)
          updt(gf[a].first, gf[a].second + 1, f[kp ^ a ^ 1]);
        tmin.inc(gf[0].second + 1, gf[1].first, -1);
        tmin.inc(gf[1].second + 1, gf[0].first, -1);
      }
      kp += 2;
    }
  tmin.push();
  tmax.push();
  for (int i(0), _b(k); i < _b; ++i) {
    pair<int, int> s = o[i];
    upd(s, pair<int, int>(tmax[i].v, tmin[i].v));
    if (s.first <= s.second && t <= g[i] + s.second && g[i] + s.first <= T) {
      int g1 = g[i], g2 = s.first;
      if (g1 + g2 < t) g2 = t - g1;
      printf("POSSIBLE\n");
      printf("%d %d\n", g1, g2);
      for (int u = 0; u < kp; u += 2) {
        if (f[u].first <= g1 && g1 <= f[u].second && f[u ^ 1].first <= g2 &&
            g2 <= f[u ^ 1].second)
          r[u] = 0;
        else
          r[u] = 1;
        r[u ^ 1] = r[u] ^ 1;
      }
      for (int j(0), _b(n); j < _b; ++j)
        if (e[j].empty()) {
          printf("%d", b[j].first <= g1 && g1 <= b[j].second ? 1 : 2);
        } else {
          printf("%d", r[p[j]] + 1);
        }
      printf("\n");
      return 0;
    }
  }
  impsy();
  return 0;
}
