#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
template <typename T>
vector<T> &operator<<(vector<T> &__container, T x) {
  __container.push_back(x);
  return __container;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &__container) {
  for (T _ : __container) out << _ << ' ';
  return out;
}
void sci() {}
template <typename... Args>
void sci(int &x, Args &...args) {
  scanf("%d", &x);
  sci(args...);
}
void scl() {}
template <typename... Args>
void scl(long long int &x, Args &...args) {
  scanf("%lld", &x);
  scl(args...);
}
const int MAXN = 2e5 + 7;
pair<int, int> A[MAXN];
int t, T, n, m, col[MAXN];
vector<int> G[MAXN];
void solve() {
  sci(t, T, n, m);
  for (int i = 1; i <= n; i++) sci(A[i].first, A[i].second);
  for (int i = 1; i <= m; i++) {
    int u, v;
    sci(u, v);
    G[u] << v;
    G[v] << u;
  }
  int n1 = INT_MAX, n2 = 0;
  for (int i = 1; i <= n; i++)
    ((n1) = (n1) < (A[i].second) ? (n1) : (A[i].second)),
        ((n2) = (n2) > (A[i].first) ? (n2) : (A[i].first));
  if (n1 + n2 < t) n2 += t - n1 - n2;
  if (n1 + n2 > T) n1 -= n1 + n2 - T;
  if (n1 < 0 or n2 < 0) {
    cout << "IMPOSSIBLE"
         << "\n";
    return;
  }
  for (int i = 1; i <= n; i++) {
    if ((A[i].second < n1 or n1 < A[i].first) and
        (A[i].second < n2 or n2 < A[i].first)) {
      cout << "IMPOSSIBLE"
           << "\n";
      return;
    }
  }
  for (int i = 1; i <= n; i++) {
    if ((A[i].first <= n1 and n1 <= A[i].second) and
        (A[i].first <= n2 and n2 <= A[i].second))
      continue;
    if (A[i].first <= n1 and n1 <= A[i].second)
      col[i] = 1;
    else
      col[i] = 2;
  }
  queue<int> que;
  for (int i = 1; i <= n; i++)
    if (col[i]) que.push(i);
  bool ok = true;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int v : G[u]) {
      if (col[v]) {
        if (col[u] == col[v]) {
          cout << "IMPOSSIBLE"
               << "\n";
          return;
        }
      } else {
        col[v] = col[u] ^ 3;
        que.push(v);
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (!col[i]) {
      que.push(i);
      col[i] = 2;
      while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int v : G[u]) {
          if (col[v]) {
            if (col[u] == col[v]) {
              cout << "IMPOSSIBLE"
                   << "\n";
              return;
            }
          } else {
            col[v] = col[u] ^ 3;
            que.push(v);
          }
        }
      }
    }
  cout << "POSSIBLE"
       << "\n";
  cout << n1 << ' ' << n2 << "\n";
  for (int i = 1; i <= n; i++) cout << col[i];
  cout << "\n";
}
int main() {
  solve();
  return 0;
}
