Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

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

int n, m, a, b, c;
vector<vector<int>> rg;

ll bfs(int s, int x) {
  vector<ll> used(x + 1, 0LL);
  queue<P> q;
  q.push({s, 0});
  while (!q.empty()) {
    int u, d;
    tie(u, d) = q.front();
    q.pop();
    if (d == x) return used[d];
    for (auto v : rg[u]) {
      if (used[d + 1] >> v & 1) continue;
      used[d + 1] |= 1LL << v;
      q.push({v, d + 1});
    } 
  }
  return 0LL;
} 

int main() {
  cin >> n >> m >> a >> b >> c;
  rg.resize(n);
  REP(i, m) {
    int u, v;
    cin >> u >> v, u--, v--;
    rg[v].push_back(u);
  }
  ll used = 0LL;
  used |= 1LL << (n - 1);
  queue<P> q;
  q.push({n - 1, 1});
  map<int, ll> bits;
  bits[a] = 0LL;
  bits[b] = 0LL;
  bits[c] = 0LL;
  while (!q.empty()) {
    int s, ans;
    tie(s, ans) = q.front();
    q.pop();
    ll all = (1LL << n) - 1;
    for (auto x : {a, b, c}) {
      auto bit = bfs(s, x);
      bits[x] |= bit;
      all &= bits[x];
    }
    REP (t, n) {
      if (~all >> t & 1) continue;
      if (t == 0) {
        cout << ans << endl;
        return 0;
      }
      if (used >> t & 1) continue;
      used |= 1LL << t;
      q.push({t, ans + 1});
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


