Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 50;

class mat {
public:
    bitset<MAX_N>* a;
    mat(){ a = new bitset<MAX_N>[MAX_N]; }
    mat operator*(const mat& m) const {
        mat ans;
        for(int i = 0; i < MAX_N; i++){
            for(int j = 0; j < MAX_N; j++){
                if(this->a[i][j] == 0) continue;
                ans.a[i] |= m.a[j];
            }
        }
        return ans;
    }
    void set(int i, int j){
        a[i].set(j);
    }
    int count(int i) const {
        return a[i].count();
    }
    int get(int i, int j) const {
        return a[i][j];
    }
};

mat pow(mat a, ll b)
{
    mat res;
    rep(i,MAX_N){
        res.set(i,i);
    }
    while(b){
        if(b & 1){
            res = res * a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}


int mx[MAX_N];
int dist[MAX_N][3];
vector<int> to[MAX_N][3];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    int a[3];
    cin >> n >> m >> a[0] >> a[1] >> a[2];
    mat A;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        A.set(y-1,x-1);
    }
    rep(i,3){
        mat res = pow(A,a[i]);
        rep(j,n){
            rep(k,n){
                if(res.get(j,k)) to[j][i].pb(k);
            }
        }
    }
    rep(i,n){
        mx[i] = dist[i][0] = dist[i][1] = dist[i][2] = INF;
    }
    mx[n-1] = dist[n-1][0] = dist[n-1][1] = dist[n-1][2] = 0;
    rep(T,1000){
        rep(j,n){
            if(mx[j] == INF) continue;
            rep(k,3){
                each(v,to[j][k]){
                    if(dist[v][k] > mx[j] + 1){
                        dist[v][k] = mx[j] + 1;
                        mx[v] = max({dist[v][0],dist[v][1],dist[v][2]});
                    }
                }
            }
        }
    }
    if(mx[0] == INF){
        cout << "IMPOSSIBLE\n";
    }else{
        cout << mx[0] << "\n";
    }
    return 0;
}
