Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 55;
vector<int> G[MAXN];
int dp[MAXN];
bool done[MAXN][2*MAXN];
const int INF = 1e9;
int n, m;

void dfs(int now, int rest, set<int>& canvisit) {
    if (done[now][rest]) return;
    done[now][rest] = true;
    if (rest == 0) {
        canvisit.insert(now);
        return;
    }
    for (int v : G[now]) {
        dfs(v, rest-1, canvisit);
    }
}

set<int> canvisit[3][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    cin >> n >> m >> a[0] >> a[1] >> a[2];
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < n; j++) {
            memset(done, false, sizeof(done));
            dfs(j, a[i], canvisit[i][j]);
        }
    }
    for (int i = 0; i < n; i++) dp[i] = INF;
    dp[n-1] = 0;
    for (int t = 0; t < n; t++) {
        for (int i = 0; i < n; i++) {
            int ans = 0;
            for (int j = 0; j < 3; j++) {
                int tmp = INF;
                for (int u : canvisit[j][i]) {
                    tmp = min(tmp, 1+dp[u]);
                }
                ans = max(ans, tmp);
            }
            dp[i] = min(dp[i], ans);
        }
    }
    if (dp[0] == INF) cout << "IMPOSSIBLE" << endl;
    else cout << dp[0] << endl;
    return 0;
}