Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M, A, B, C;
  cin >> N >> M >> A >> B >> C;
  vector<vector<ll>> E(N);
  REP(i, 0, M) {
    ll U, V;
    cin >> U >> V, U--, V--;
    E[V].push_back(U);
  }

  vector<bool> s(N);
  s[N - 1] = true;

  for (ll ans = 1;; ans++) {
    vector<vector<bool>> dp(101, vector<bool>(N));
    REP(v, 0, N) dp[0][v] = s[v];

    REP(k, 0, 100) {
      REP(v, 0, N) {
        if (dp[k][v]) {
          REP(i, 0, E[v].size()) {
            ll u = E[v][i];
            dp[k + 1][u] = true;
          }
        }
      }
    }

    bool br = true;
    REP(v, 0, N) {
      if (!s[v] && dp[A][v] && dp[B][v] && dp[C][v]) {
        s[v] = true;
        br = false;
        if (v == 0) {
          cout << ans << endl;
          return 0;
        }
      }
    }
    if (br) break;
  }

  cout << "IMPOSSIBLE" << endl;
}
