#include <bits/stdc++.h>
using namespace std;
int n, m, t, T;
int x, y;
vector<int> g[100005];
int c[100005], l[100005], r[100005];
bool dfs(int x) {
  for (auto y : g[x]) {
    if (!c[y]) {
      c[y] = 3 - c[x];
      if (!dfs(y)) return 0;
    } else if (c[x] == c[y])
      return 0;
  }
  return 1;
}
bool pd(int x, int i) { return x >= l[i] && x <= r[i]; }
int main() {
  cin >> t >> T >> n >> m;
  for (int i = 1; i <= n; i++) cin >> l[i] >> r[i];
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    g[x].push_back(y), g[y].push_back(x);
  }
  int t1 = 0x3f3f3f3f, t2 = 0;
  for (int i = 1; i <= n; i++) t1 = min(t1, r[i]), t2 = max(t2, l[i]);
  if (t1 + t2 < t) t2 = t - t1;
  if (t1 + t2 > T) t1 = T - t2;
  if (t1 < 0 || t2 < 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    bool a = 0, b = 0;
    if (t1 >= l[i] && t1 <= r[i]) a = 1;
    if (t2 >= l[i] && t2 <= r[i]) b = 1;
    if (!a && !b) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    if (a && !b) c[i] = 1;
    if (!a && b) c[i] = 2;
  }
  for (int i = 1; i <= n; i++)
    if (c[i] && (!dfs(i))) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    if (!c[i]) {
      c[i] = 1;
      if (!dfs(i)) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "POSSIBLE" << endl;
  cout << t1 << " " << t2 << endl;
  for (int i = 1; i <= n; i++) cout << c[i];
  return 0;
}
