Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = (int)1e9;

bool G[101][51][51];

int main() {
  int n, m;
  vi steps(3);
  cin >> n >> m >> steps[0] >> steps[1] >> steps[2];
  REP(i, m){
    int from, to;
    cin >> from >> to;
    G[0][from][to] = true;
  }

  FOR(c, 1, 101){
    FOR(j, 1, n + 1) FOR(i, 1, n + 1){
      FOR(k, 1, n + 1){
        G[c][j][i] |= G[c - 1][j][k] && G[0][k][i];
      }
    }
  }
  // REP(c,  5){
  //   FOR(j, 1, n + 1){
  //     FOR(i, 1, n + 1){
  //       LOG("%d ", G[c][j][i] ? 1 : 0);
  //     }
  //     LOG("\n");
  //   }
  //   LOG("--------------------\n");
  // }

  vvi taketurn(n + 1, vi(4, INF));
  taketurn[n][3] = 0;
  queue<int> que;
  que.push(n);
  while(!que.empty()) {
    int to = que.front(); que.pop();
    FOR(from, 1, n){
      REP(i, steps.size()){
        int step = steps[i];
        if(G[step - 1][from][to]) {
          // LOG("--->> %d -> %d step %d\n", from, to, step);
          taketurn[from][i] = min(taketurn[from][i], taketurn[to][3] + 1);
        }
      }
      int res = min(taketurn[from][3], max(taketurn[from][0], max(taketurn[from][1], taketurn[from][2])));
      if (taketurn[from][3] > res) {
        taketurn[from][3] = res;
        if(from == 1) {
          cout << taketurn[from][3] << endl;
          goto END;
        }
        que.push(from);
      }
    }
  }


  cout << "IMPOSSIBLE" << endl;

END:
  {}
  // FOR(i, 1, n + 1){
  //   LOG("%d ", taketurn[i][3]);
  // }
  // LOG("\n");
}