// 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.309393068329776x):
#include <bits/stdc++.h>



using namespace std;

const int INF = 1000000000;

int n, m, a[3];

int go[110][60][60], ok[60];

int matrix[60][60], dp[60][3], dp2[60];

int main(){

//freopen("in.txt", "r", stdin);

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

    for (int i = 1; i <= m; ++ i){

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

        matrix[v][u] = 1;

    }

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

    for (int k = 1; k <= 100; ++ k){

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

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

                if (go[k - 1][i][j] == 0) continue;

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

                    //if (k == 1 && i == 8 && l == 1) printf("%d\n", j);

                    go[k][i][l] |= go[k - 1][i][j] & matrix[j][l];

                }

            }

        }

    }

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

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

            dp[i][j] = INF;

        }

        dp2[i] = INF;

    }



    queue <int> q;

    q.push(n); dp2[n] = 0;

    while (!q.empty()){

        int h = q.front(); q.pop();



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

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

                if (go[a[i]][h][j]){

                    if (dp2[h] + 1 < dp[j][i]){



                        ok[j] |= 1 << i;

                        dp[j][i] = dp2[h] + 1;



                        if (ok[j] == 7){

                            dp2[j] = *max_element(dp[j], dp[j] + 3);

                            q.push(j);

                        }

                    }

                }

            }

        }

    }

    //printf("%d\n", go[0][8][1]);

    int ans = dp2[1];

    if (ans == INF) puts("IMPOSSIBLE");

    else{

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

    }

}