#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1e5 + 4;
pair<int, int> regs[maxn];
int col[maxn];
vector<int> verts[maxn];
void dfs(int u, int cc) {
  if (col[u]) {
    if (cc == col[u])
      return;
    else
      throw exception();
  }
  col[u] = cc;
  for (int v : verts[u]) dfs(v, cc ^ 1);
}
int main() {
  int n1 = 0x3f3f3f3f, n2 = 0;
  int Tr, Tl;
  int N, M;
  cin >> Tl >> Tr >> N >> M;
  for (int i = 1; i <= N; ++i) {
    cin >> regs[i].first >> regs[i].second;
    n1 = min(n1, regs[i].second);
    n2 = max(n2, regs[i].first);
  }
  for (int i = 1; i <= M; ++i) {
    int a, b;
    cin >> a >> b;
    verts[a].push_back(b);
    verts[b].push_back(a);
  }
  if (n1 + n2 < Tl)
    n2 = Tl - n1;
  else if (n1 + n2 > Tr)
    n1 = Tr - n2;
  try {
    if (n1 < 0) throw exception();
    for (int i = 1; i <= N; ++i) {
      if (((regs[i]).first > (n1) || (regs[i]).second < (n1))) dfs(i, 3);
      if (((regs[i]).first > (n2) || (regs[i]).second < (n2))) dfs(i, 2);
    }
    for (int i = 1; i <= N; ++i)
      if (!col[i]) dfs(i, 2);
    cout << "POSSIBLE" << endl;
    cout << n1 << " " << n2 << endl;
    for (int i = 1; i <= N; ++i) cout << col[i] - 1;
    cout << endl;
  } catch (...) {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}
