Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <complex>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)
#define RREP(i, n) for(int i=n-1;i>=0;i--)
#define RREPS(i, n) for(int i=n;i>0;i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define pb push_back
#define eb emplace_back
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int T, n, m, a, b, c;

vector<vi> mul(const vector<vi> &a, const vector<vi> &b){
	vector<vi> res(n, vi(n));
	REP(i, a.size())REP(j, b.size())REP(k, b.size())
		res[i][j] |= a[i][k] & b[k][j];
	return res;
}

vector<vi> pow(const vector<vi> &g, int b){
	if(b == 0){
		vector<vi> gg(n, vi(n));
		REP(i, n) gg[i][i] = 1;
		return gg;
	}
	auto res = pow(mul(g, g), b/2);
	if(b&1) res = mul(res, g);
	return res;
}	
int main(){
	cin >> n >> m >> a >> b >> c;
	vector<vi> gg(n, vi(n));
	REP(i, m){
		int u, v;
		cin >> u >> v; u--; v--;
		gg[u][v] = 1;
	}
	vector<vector<vi>> g({pow(gg, a), pow(gg, b), pow(gg, c)});
	vi dp(n, 1<<29);
	dp[n-1] = 0;
	REP(_, n)REP(u, n){
		vi c(3, 1<<29);
		REP(i, 3)REP(v, n)if(g[i][u][v]){
			c[i] = min(c[i], dp[v] + 1);
		}
		dp[u] = min(dp[u], *max_element(ALL(c)));
	}
	if(dp[0] == (1<<29)) cout << "IMPOSSIBLE" << endl;
	else cout << dp[0] << endl;
	return 0;
}