Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

vector<int> G[52];
int n,m;
int a,b,c;
int steps[3];
int d[52];
int goal;
int dp[52][52][102];

bool dfs(int v,int u,int a) {
    if(a==0) {
        return v==u;
    }
    if(dp[v][u][a]!=-1) return dp[v][u][a];
    bool f=false;
    rep(i,G[v].size()) {
        f|=dfs(G[v][i],u,a-1);
    }

    return dp[v][u][a]=f;
}

int nextCost(int u) {
    int ret=-1;
    rep(i,3) {
        int t=INF;
        rep(v,n) {
            if(dfs(v,u,steps[i])) {
                t=min(t,d[v]);
            }
        }

        ret=max(ret,t);
    }

    return ret;
}

void bfs() {
    d[goal]=0;
    bool f=true;
    while(f) {
        f=false;
        //printf("debug %d %d\n",v,d[v]);
        rep(u,n) {
            int t=nextCost(u);
            if(t==-1||t==INF) continue;
            if(d[u]>t+1) {
                f=true;
                d[u]=t+1;
            }
        }
    }
}

int main() {
    rep(i,52) d[i]=INF;
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    cin>>a>>b>>c;
    steps[0]=a; steps[1]=b; steps[2]=c;
    goal = n-1;
    rep(i,m) {
        int s,t;
        cin>>s>>t; s--;t--;
        G[t].pb(s);
    }
    bfs();
    int ans=d[0];

    if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}