Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
/*************************************************************************
	> File Name: c.cpp
	> Author: skt
	> Mail: sktsxy@gmail.com
	> Created Time: 2015??´11???29??\ ????????\ 10??¶26???44?§?
 ************************************************************************/

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <cassert>
// #pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define MAXN 55
#define MOD 1000000007
template <typename T> inline void checkMax(T &a, T b) {a = a>b?a:b;}
template <typename T> inline void checkMin(T &a, T b) {a = a<b?a:b;}
typedef pair<int, int> PII;
typedef vector<int> vi;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3fffffff;

int N, M, a, b, c;

LL g[MAXN][MAXN], len[MAXN];

LL A[MAXN][MAXN], B[MAXN][MAXN], C[MAXN][MAXN];

bool vis[MAXN], ok[MAXN];

void matrix_product(LL a[][MAXN], LL b[][MAXN]) {
    LL c[MAXN][MAXN] = {};
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= N; j ++) {
            for (int k = 1; k <= N; k ++) {
                c[i][j] = c[i][j] + a[i][k] * b[k][j];
                c[i][j] %= MOD;
            }
        }
    }
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= N; j ++) {
            a[i][j] = c[i][j];
        }
    }
}

void matrix_power(LL ans[][MAXN], LL a[][MAXN], int n) {
    LL tmp[MAXN][MAXN] = {};
    for (int i = 1; i <= N; i ++) {
        for (int j = 1; j <= N; j ++) {
            tmp[i][j] = a[i][j];
        }
    }
    while (n) {
        if (n & 1) matrix_product(ans, tmp);
        matrix_product(tmp, tmp);
        n >>= 1;
    }
}

void bfs(int start) {
    fill(len, len + MAXN, INF);
    memset(vis, 0, sizeof(vis));
    memset(ok, 0, sizeof(ok));
    vis[start] = true;
    len[start] = 0;
    queue<int> Q;
    Q.push(start);
    int cnt[MAXN][3] = {};
    while (!Q.empty()) {
        vector<int> vec;
        LL step[MAXN][3] = {};
        for (int i = 1; i <= N; i ++) step[i][0] = step[i][1] = step[i][2] = INF;
        while (!Q.empty()) {
            int now = Q.front(); Q.pop();
            ok[now] = true;
        }
        for (int i = 1; i <= N; i ++) {
            if (!ok[i]) continue;
            for (int j = 1; j <= N; j ++) {
                if (A[j][i] && !vis[j]) {
                    cnt[j][0] ++;
                    step[j][0] = min(step[j][0], len[i] + 1);
                }
                if (B[j][i] && !vis[j]) {
                    cnt[j][1] ++;
                    step[j][1] = min(step[j][1], len[i] + 1);
                }
                if (C[j][i] && !vis[j]) {
                    cnt[j][2] ++;
                    step[j][2] = min(step[j][2], len[i] + 1);
                }
            }
        }
        for (int i = 1; i <= N; i ++) {
            if (vis[i]) continue;
            if (cnt[i][0] && cnt[i][1] && cnt[i][2]) {
                len[i] = max(step[i][0], max(step[i][1], step[i][2]));
                vis[i] = true;
                Q.push(i);
            }
        }
    }
}

void work() {
    memset(g, 0, sizeof(g));
    for (int i = 1; i <= M; i ++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u][v] = 1;
    }
    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    memset(C, 0, sizeof(C));
    for (int i = 1; i <= N; i ++) A[i][i] = B[i][i] = C[i][i] = 1;
    matrix_power(A, g, a);
    matrix_power(B, g, b);
    matrix_power(C, g, c);
    bfs(N);
    if (len[1] == INF) {
        printf("IMPOSSIBLE\n");
    } else {
        int ans = len[1];
        printf("%d\n", ans);
    }
}
int main() {
#ifdef __SKT__
    freopen("in", "r", stdin);
#endif
    while (scanf("%d %d %d %d %d", &N, &M, &a, &b, &c) != EOF) {
        work();
    }
    return 0;
}