#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& t) {
  T f = 1;
  char ch = getchar();
  t = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  t *= f;
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
int t, T, n, m;
int n1 = 1e9, n2 = -1e9;
int l[100005], r[100005];
char ans[100005];
inline bool pd(int i, int x) { return l[i] <= x && x <= r[i]; }
vector<int> edge[100005];
bool dfs(int now) {
  for (int i = 0; i < edge[now].size(); i++)
    if (ans[edge[now][i]] == 0) {
      ans[edge[now][i]] = 3 - ans[now];
      if (dfs(edge[now][i]) == 0) return 0;
    } else if (ans[edge[now][i]] == ans[now])
      return 0;
  return 1;
}
int main() {
  read(t, T, n, m);
  for (int i = 1; i <= n; i++)
    read(l[i], r[i]), n1 = min(n1, r[i]), n2 = max(n2, l[i]);
  if (n1 + n2 < t) n2 = t - n1;
  if (n1 + n2 > T) n1 = T - n2;
  if (n1 < 0 || n2 < 0) return printf("IMPOSSIBLE\n"), 0;
  for (int i = 1; i <= n; i++) {
    if (pd(i, n1) == 0 && pd(i, n2) == 0) return printf("IMPOSSIBLE\n"), 0;
    if (pd(i, n1) == 1 && pd(i, n2) == 0) ans[i] = 1;
    if (pd(i, n1) == 0 && pd(i, n2) == 1) ans[i] = 2;
  }
  for (int i = 1, x, y; i <= m; i++) {
    read(x, y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (ans[i])
      if (dfs(i) == 0) return printf("IMPOSSIBLE\n"), 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] == 0) {
      ans[i] = 1;
      if (dfs(i) == 0) return printf("IMPOSSIBLE\n"), 0;
    }
  printf("POSSIBLE\n%d %d\n", n1, n2);
  for (int i = 1; i <= n; i++) ans[i] += '0';
  printf("%s\n", ans + 1);
  return 0;
}
