Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    
    int n, m;
    int a[3];
    cin >> n >> m;
    rep(i, 3) cin >> a[i];
    
    vector<int> g[n];
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        g[s].eb(t);
    }
    
    set<int> to[n][107];
    // iからj stepで行けるとこ
    // bfsだけどqueueでやると無限ループもあるし...
    // rep(cnt, 106) {
        rep(v, n) { // vからiで行けるとこ
            // if (cnt == 0) {
                for (int nxt : g[v]) {
                    to[v][1].insert(nxt);
                }
            // }
            rep3(i, 2, 105) {
                // vからi-1で行けるとこから行けるとこ
                for (int now : to[v][i - 1]) {
                    for (int nxt : g[now]) {
                        to[v][i].insert(nxt);
                    }
                }
            }
        }
    // }
    /*
    rep(v, n) rep(i, 5) {
        cout << v << " " << i << endl;
        for (int tmp : to[v][i]) cout << tmp << " "; cout << endl;
    }
    */
    vector<int> d(n, inf);
    d[n - 1] = 0;
    int cnt = 0;
    while (1) {
        cnt++;
        if (cnt == 2 * n) {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        
        int update = 0;
        rep(v, n) {
            int tD = 0;
            rep(i, 3) {
                int D = inf;
                for (int va : to[v][a[i]]) {
                    chmin(D, d[va]);
                }
                // cout << v << " " << a[i] << " " << D << endl;
                chmax(tD, D);
            }
            tD++;
            if (tD < d[v]) {
                update = 1;
                d[v] = tD;
            }
        }
        if (update == 0) break;
    }
    if (d[0] != inf) cout << d[0] << endl;
    else cout << "IMPOSSIBLE" << endl;
}




