#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline string tostr(const T& x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
inline long long parse(const string& s) {
  stringstream ss(s);
  long long x;
  ss >> x;
  return x;
}
const double EPS = 1e-9;
const int inf = 1000 * 1000 * 1000;
const char cinf = 102;
const long long linf = inf * 1ll * inf;
const double dinf = 1e200;
const double PI = 3.1415926535897932384626433832795l;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long p, long long m) {
  long long r = 1;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
struct segtree {
  vector<int> T, D;
  segtree(int n) : T(n * 4 + 10), D(n * 4 + 10) {}
  void add(int l, int r, int v, int a, int b, int k) {
    if (l >= b || r <= a) return;
    if (l <= a && r >= b) {
      D[k] += v;
      T[k] += v;
      return;
    }
    int c = (a + b) / 2;
    add(l, r, v, a, c, k * 2 + 1);
    add(l, r, v, c, b, k * 2 + 2);
    T[k] = D[k] + max(T[k * 2 + 1], T[k * 2 + 2]);
  }
  int find(int a, int b, int k) {
    if (b == a + 1) return a;
    int c = (a + b) / 2;
    if (T[k * 2 + 1] > T[k * 2 + 2])
      return find(a, c, k * 2 + 1);
    else
      return find(c, b, k * 2 + 2);
  }
};
struct group {
  int l[2]{0, 0}, r[2];
  vector<pair<int, int>> id;
  group(int c) : r{c, c} {}
};
pair<pair<int, int>, string> solve(int tt, int TT, vector<pair<int, int>> R,
                                   vector<pair<int, int>> E) {
  int n = ((int)(R).size());
  vector<int> xs = {0, tt, TT};
  for (int i = 0; i < (n); ++i) {
    xs.push_back(R[i].first);
    xs.push_back(max(0, tt - R[i].first));
    xs.push_back(max(0, TT - R[i].first));
    xs.push_back(R[i].second - 1);
    xs.push_back(max(0, tt - (R[i].second - 1)));
    xs.push_back(max(0, TT - (R[i].second - 1)));
  }
  sort((xs).begin(), (xs).end());
  xs.erase(unique((xs).begin(), (xs).end()), xs.end());
  for (auto& x : R) {
    x.first = lower_bound((xs).begin(), (xs).end(), x.first) - xs.begin();
    x.second = lower_bound((xs).begin(), (xs).end(), x.second) - xs.begin();
  }
  vector<group> G;
  {
    vector<vector<int>> gr(n);
    for (int i = 0; i < (((int)(E).size())); ++i) {
      gr[E[i].first].push_back(E[i].second);
      gr[E[i].second].push_back(E[i].first);
    }
    vector<char> was(n);
    for (int v0 = 0; v0 < (n); ++v0) {
      if (was[v0]) continue;
      group g(((int)(xs).size()));
      bool ok = true;
      function<void(int, int)> dfs;
      dfs = [&](int v, int s) {
        if (was[v]) {
          if (was[v] - 1 != s) ok = false;
          return;
        }
        was[v] = 1 + s;
        g.l[s] = max(g.l[s], R[v].first);
        g.r[s] = min(g.r[s], R[v].second);
        g.id.push_back(make_pair(v, s));
        for (int p : gr[v]) dfs(p, 1 - s);
      };
      dfs(v0, 0);
      if (!ok) return make_pair(make_pair(-1, -1), "");
      G.push_back(g);
    }
  }
  struct event {
    int x;
    int a, b, s;
    bool operator<(const event& e) const { return x < e.x; }
  };
  vector<event> evs;
  for (group& g : G) {
    vector<int> p = {g.l[0], g.l[1], g.r[0], g.r[1]};
    sort((p).begin(), (p).end());
    p.erase(unique((p).begin(), (p).end()), p.end());
    assert(((int)(p).size()) > 1);
    for (int i = 0; i < (((int)(p).size()) - 1); ++i) {
      int l = inf, r = -inf;
      if (p[i] >= g.l[0] && p[i] < g.r[0])
        l = min(l, g.l[1]), r = max(r, g.r[1]);
      if (p[i] >= g.l[1] && p[i] < g.r[1])
        l = min(l, g.l[0]), r = max(r, g.r[0]);
      if (l == inf) continue;
      evs.push_back({p[i], l, r, +1});
      evs.push_back({p[i + 1], l, r, -1});
    }
  }
  for (int i = 0; i < (((int)(xs).size())); ++i) evs.push_back({i, 0, 0, 0});
  sort((evs).begin(), (evs).end());
  segtree T(((int)(xs).size()));
  for (int q = 0; q < (((int)(evs).size())); ++q) {
    event e = evs[q];
    if (e.s) T.add(e.a, e.b, e.s, 0, ((int)(xs).size()), 0);
    if (q + 1 == ((int)(evs).size()) || evs[q + 1].x != evs[q].x) {
      int l = lower_bound((xs).begin(), (xs).end(), tt - xs[e.x]) - xs.begin();
      int r = upper_bound((xs).begin(), (xs).end(), TT - xs[e.x]) - xs.begin();
      T.add(l, r, +1, 0, ((int)(xs).size()), 0);
      int tv = T.T[0];
      if (T.T[0] == ((int)(G).size()) + 1) {
        int n1 = e.x;
        int n2 = T.find(0, ((int)(xs).size()), 0);
        assert(xs[n1] + xs[n2] >= tt && xs[n1] + xs[n2] <= TT);
        string res(n, '?');
        for (group& g : G) {
          int s;
          if (g.l[0] <= n1 && g.r[0] > n1 && g.l[1] <= n2 && g.r[1] > n2)
            s = 0;
          else if (g.l[1] <= n1 && g.r[1] > n1 && g.l[0] <= n2 && g.r[0] > n2)
            s = 1;
          else
            assert(false);
          for (auto& p : g.id) {
            res[p.first] = '1' + (p.second != s);
          }
        }
        return make_pair(make_pair(xs[n1], xs[n2]), res);
      }
      T.add(l, r, -1, 0, ((int)(xs).size()), 0);
    }
  }
  return make_pair(make_pair(-1, -1), "");
}
pair<pair<int, int>, string> brute(int tt, int TT, vector<pair<int, int>> R,
                                   vector<pair<int, int>> E) {
  int n = ((int)(R).size());
  for (int m = 0; m < (1 << n); ++m) {
    int l[2] = {0, 0}, r[2] = {inf + 1, inf + 1};
    for (int i = 0; i < (n); ++i) {
      int t = (m >> i) & 1;
      l[t] = max(l[t], R[i].first);
      r[t] = min(r[t], R[i].second - 1);
    }
    bool ok = true;
    for (pair<int, int> e : E) {
      ok &= ((m >> e.first) % 2 != (m >> e.second) % 2);
    }
    if (!ok) continue;
    if (l[0] <= r[0] && l[1] <= r[1] && l[0] + l[1] <= TT &&
        r[0] + r[1] >= tt) {
      int n1 = max(l[0], tt - r[1]);
      int n2 = max(l[1], tt - n1);
      assert(n1 <= r[0] && n2 <= r[1] && n1 + n2 <= TT);
      string res(n, '1');
      for (int i = 0; i < (n); ++i) {
        if (m & (1 << i)) res[i] = '2';
      }
      return make_pair(make_pair(n1, n2), res);
    }
  }
  return make_pair(make_pair(-1, -1), "");
}
void stress() {
  for (int n = 1; n < 10; ++n) {
    for (int m = 0; m < 10; ++m) {
      for (int lim : {10, inf}) {
        for (int q = 0; q < (10000); ++q) {
          int tt = rand() % lim + 1;
          int TT = rand() % lim + 1;
          if (TT < tt) swap(tt, TT);
          vector<pair<int, int>> R(n);
          for (int i = 0; i < (n); ++i) {
            R[i] = make_pair(rand() % (lim + 1), rand() % (lim + 1));
            if (R[i].second < R[i].first) swap(R[i].first, R[i].second);
            ++R[i].second;
          }
          vector<pair<int, int>> E(m);
          for (int i = 0; i < (m); ++i) {
            E[i] = make_pair(rand() % n, rand() % n);
          }
          {
            ofstream sout("in.txt");
            sout << tt << ' ' << TT << '\n' << n << ' ' << m << '\n';
            for (int i = 0; i < (n); ++i) {
              sout << R[i].first << ' ' << R[i].second - 1 << '\n';
            }
            for (int i = 0; i < (m); ++i) {
              sout << E[i].first + 1 << ' ' << E[i].second + 1 << '\n';
            }
          }
          auto b = brute(tt, TT, R, E);
          auto r = solve(tt, TT, R, E);
          if ((r.first.first == -1) != (b.first.first == -1)) {
            cerr << "failed " << n << ' ' << m << ' ' << lim << ' ' << q << ":"
                 << endl;
            cerr << b.first.first << ' ' << b.first.second << ' ' << b.second
                 << endl;
            cerr << r.first.first << ' ' << r.first.second << ' ' << r.second
                 << endl;
            cout << tt << ' ' << TT << '\n' << n << ' ' << m << '\n';
            for (int i = 0; i < (n); ++i) {
              cout << R[i].first << ' ' << R[i].second - 1 << '\n';
            }
            for (int i = 0; i < (m); ++i) {
              cout << E[i].first + 1 << ' ' << E[i].second + 1 << '\n';
            }
            return;
          }
        }
      }
    }
  }
  cerr << "passed" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt, TT;
  cin >> tt >> TT;
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> R(n);
  for (int i = 0; i < (n); ++i) {
    cin >> R[i].first >> R[i].second;
    ++R[i].second;
  }
  vector<pair<int, int>> E(m);
  for (int i = 0; i < (m); ++i) {
    cin >> E[i].first >> E[i].second;
    --E[i].first;
    --E[i].second;
  }
  auto r = solve(tt, TT, R, E);
  if (r.first.first == -1) {
    cout << "IMPOSSIBLE";
  } else {
    cout << "POSSIBLE\n"
         << r.first.first << ' ' << r.first.second << '\n'
         << r.second << endl;
  }
  return 0;
}
