// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int MAXN=55;



bool  w[MAXN][MAXN],f[MAXN][MAXN][105];

int vis[MAXN];



int main()

{

    int n,m,len[3];

    scanf("%d%d",&n,&m);

    memset(w,0,sizeof(w));memset(f,0,sizeof(f));memset(vis,0,sizeof(vis));

    for (int i=0;i<3;i++) scanf("%d",&len[i]);

    for (int u,v;m--;)

    {

        scanf("%d%d",&u,&v);

        w[u][v]=true;

    }

    for (int i=1;i<=n;i++)

    {

        f[i][i][0]=true;

        for (int j=1;j<=100;j++)

            for (int k=1;k<=n;k++)

                for (int l=1;l<=n;l++)

                    if (w[l][k]&&f[i][l][j-1])

                        f[i][k][j]=true;

    }

    fill(vis+1,vis+n,INT_MAX);

    for (int now=1;now<=n;now++)

        for (int i=1;i<=n;i++)

            if (vis[i]>now)

            {

                bool flag;

                for (int j=0;j<3;j++)

                {

                    flag=false;

                    for (int k=1;k<=n;k++)

                        if (vis[k]<now&&f[i][k][len[j]])

                        {

                            flag=true;

                            break;

                        }

                    if (!flag) break;

                }

                if (flag)

                {

                    if (i==1)

                    {

                        printf("%d\n",now);

                        return 0;

                    }

                    vis[i]=now;

                }

            }

    puts("IMPOSSIBLE");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3018096540973516x):
#include<bits/stdc++.h>



using namespace std;



inline int get_int() {

    int res, c, t = 1;

    while(!isdigit(c = getchar())) if(c == '-') t = -1;

    for(res = c - '0'; isdigit(c = getchar()); )

        res = res * 10 + c - '0';

    return res * t;

}



#define rep(i, x) for(int i = 0; i < (int)(x); i++)



typedef long long LL;

typedef pair<int, int> pii;

typedef long double ld;

typedef unsigned int uint;



const int INF = 0x3f3f3f3f;

const double EPS = 1e-7;

const double PI = acos(-1);



const int MAXN = 100;



int n, m, BU[3];

vector<int> G[MAXN + 10];



bool dp1[105][MAXN + 2][MAXN + 2];



void getDp1() {

    for(int i = 1; i <= n; i++) dp1[0][i][i] = 1;



    for(int len = 0; len <= 101; len++) {

        for(int u = 1; u <= n; u++) {

            for(int v = 1; v <= n; v++) {

                if(dp1[len][u][v]) {

                    rep(i, G[v].size()) {

                        int w = G[v][i];

                        dp1[len + 1][u][w] = 1;

                    }

                }

            }

        }

    }



}

int getDp3() {

    static int dp[MAXN + 10];

    static int da[MAXN + 10], db[MAXN + 10], dc[MAXN + 10];

    memset(dp, -1, sizeof(dp));

    dp[n] = 0;



    queue<int> q;

    q.push(n);



    while(!q.empty()) {

        int u = q.front();

        q.pop();

        for(int v = 1; v <= n; v++) if(dp[v] == -1) {

            if(!da[v] && dp1[BU[0]][v][u]) da[v] = dp[u] + 1;

            if(!db[v] && dp1[BU[1]][v][u]) db[v] = dp[u] + 1;

            if(!dc[v] && dp1[BU[2]][v][u]) dc[v] = dp[u] + 1;

            if(da[v] && db[v] && dc[v])

                dp[v] = max(da[v], max(db[v], dc[v])), q.push(v);

        }

    }





    /*for(int T = 1; T <= n*2; T++) {

        for(int u = 1; u <= n; u++) if(dp[u] == -1) {

            int Max = 0;

            for(int it = 0; it < 3; it++) {

                int step = BU[it];

                int Min = INF;

                for(int v = 1; v <= n; v++) if(dp1[step][u][v] && dp[v] != -1)

                    Min = dp[v]+1;

                Max = max(Max, Min);

            }

            if(Max != INF)

                dp[u] = Max;

        }

    }

*/

    return dp[1];

}



int main() {



    scanf("%d%d%d%d%d", &n, &m, &BU[0], &BU[1], &BU[2]);

    rep(i, m) {

        int u, v;

        cin >> u >> v;

        G[u].push_back(v);

    }



    getDp1();

    int ans = getDp3();

    if(ans == -1) puts("IMPOSSIBLE");

    else cout << ans << endl;



    return 0;

}