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<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
const int INF = 1010101010;
bool can[110][55][55];
int step[55];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int a[3];
    cin >> n >> m;
    rep(i,3) cin >> a[i];
    vector<vector<int> > G(n);
    rep(i,m){
        int u,v;
        cin >> u >> v;
        u--; v--;
        G[u].pb(v);
    }
    rep(i,n) can[0][i][i] = 1;
    // 子からi歩 ==> 親からi+1歩
    rep(i,100)rep(u,n)for(auto &v:G[u])rep(j,n){
        if(can[i][v][j]) can[i+1][u][j] = 1;
    }
    rep(i,n) step[i] = INF;
    step[n-1] = 0;
    bool f = 1;
    while(f){
        f = 0;
        rep(u,n){
            int tmp = -1;
            rep(j,3){
                int mn = INF;
                rep(v,n) if(can[a[j]][u][v]) mn = min(mn, step[v]+1);
                tmp = max(tmp, mn);
            }
            if(tmp < step[u]){
                f = 1;
                step[u] = tmp;
            }
        }
    }

    if(step[0] == INF) cout << "IMPOSSIBLE" << endl;
    else cout << step[0] << endl;
    
}

