#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10, MN = 2e6 + 10;
void fail() {
  cout << "IMPOSSIBLE\n";
  exit(0);
}
int l[MN], r[MN], id[MN], L, R, n, m, n1 = INF, n2;
vector<int> g[MN];
void dfs(int i, int x) {
  if (id[i]) {
    if (id[i] == x) return;
    fail();
  }
  id[i] = x;
  for (auto y : g[i]) dfs(y, 3 - x);
}
bool F(int i, int x) { return l[i] <= x && r[i] >= x; }
void init() {
  cin >> L >> R >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> l[i] >> r[i];
    n1 = min(n1, r[i]);
    n2 = max(n2, l[i]);
  }
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
}
void solve() {
  if (n1 + n2 < L) n2 = L - n1;
  if (n1 + n2 > R) n1 = R - n2;
  if (n1 < 0 || n2 < 0) fail();
  for (int i = 1; i <= n; ++i) {
    if (F(i, n1)) {
      if (!F(i, n2)) dfs(i, 1);
    } else if (F(i, n2))
      dfs(i, 2);
    else
      fail();
  }
  for (int i = 1; i <= n; ++i)
    if (!id[i]) dfs(i, 1);
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  init();
  solve();
  cout << "POSSIBLE\n";
  cout << n1 << ' ' << n2 << '\n';
  for (int i = 1; i <= n; ++i) cout << id[i];
  cout << '\n';
  return 0;
}
