Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

#define int ll

int dist[100];
int neko[100];
vector<int> vertexs[100];
vector<int> visitings[3][100];
void solve(){
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        swap(a, b);
        vertexs[a].push_back(b);
    }
    REP(i, n) {
        int cnt[51][101] = {};
        cnt[i][0] = 1;
        for (int q = 0; q < 100; ++q) {
            REP(j, n) {
                if (cnt[j][q] == 0) continue;
                for (auto x : vertexs[j]) {
                    cnt[x][q + 1] = 1;
                }
            }
        }
        REP(q, n) {
            if (cnt[q][a] == 1) visitings[0][i].push_back(q);
            if (cnt[q][b] == 1) visitings[1][i].push_back(q);
            if (cnt[q][c] == 1) visitings[2][i].push_back(q);
        }
        dist[i] = 1e9;
    }
    dist[n - 1] = 0;
    neko[n - 1] = 7;
    queue<int> next;
    next.push(n - 1);
    while (next.empty() == false) {
        int now = next.front();
        next.pop();
        REP(q, 3) {
            for (auto x : visitings[q][now]) {
                if (neko[x] & (1 << q)) {
                    continue;
                }
                neko[x] |= (1 << q);
                if (neko[x] == 7) {
                    dist[x] = dist[now] + 1;
                    next.push(x);
                }
            }
        }
    }
    if (dist[0] == 1e9) {
        cout << "IMPOSSIBLE" << endl;
    }
    else {
        cout << dist[0] << endl;
    }
    
}

#undef int
int main() {
    init();
    solve();
}
