Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define int long long
const int INF = (int)1e9;
int N, M, STEP[3];
vector<vector<int>> G;
bool canMove[50][50][101];
int winning[50];
signed main() {
  ios::sync_with_stdio(false);
  cin >> N >> M >> STEP[0] >> STEP[1] >> STEP[2];
  G.resize(N);
  REP(i,M) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
  }
  memset(canMove, 0, sizeof(canMove));
  REP(i,N) canMove[i][i][0] = true;
  REP(d,100) {
    REP(i,N) REP(j,N) {
      if(canMove[i][j][d]) {
        for(int k : G[j]) canMove[i][k][d + 1] = true;
      }
    }
  }
  REP(i,N) winning[i] = INF;
  winning[N - 1] = 0;
  while(true) {
    bool update = false;
    REP(v,N) {
      int mx = 0;
      REP(k,3) {
        int mn = INF;
        REP(u,N) {
          if(canMove[v][u][STEP[k]]) {
            mn = min(mn, winning[u] + 1);
          }
        }
        mx = max(mx, mn);
      }
      if(winning[v] > mx) {
        winning[v] = mx;
        update = true;
      }
    }
    if(!update) break;
  }
  if(winning[0] == INF) {
    cout << "IMPOSSIBLE" << endl;
  }
  else {
    cout << winning[0] << endl;
  }
}