Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

int N, M;
int A[3];
VI G[51];
VI G_[51][3];
void calc(){
  for(int u=1;u<=N;++u){
	REP(i,3){
	  int crt = 0, nxt = 1;
	  set<int> s[2];
	  s[crt].insert(u);
	  REP(turn,A[i]){
		s[nxt].clear();
		for(int v: s[crt])
		  for(int to: G[v])
			s[nxt].insert(to);
		swap(crt, nxt);
	  }
	  for(int v: s[crt])
		G_[u][i].PB(v);
	}
  }
}

int dp[51];
/*
int solve(int u){
  if(u == N) return dp[u] = 0;
  if(dp[u] >= 0) return dp[u];
  int res = 0;
  dp[u] = INF;
  REP(i,3){
	int tmp = INF;
	for(int to: G_[u][i])
	  tmp = min(tmp, solve(to)+1);
	res = max(res, tmp);
  }
  return dp[u] = res;
}
*/

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> M >> A[0] >> A[1] >> A[2];
  REP(i,M){
	int u, v; cin >> u >> v;
	G[u].PB(v);
  }
  calc();
  fill((int*)dp, (int*)dp+51, INF);

  dp[N] = 0;
  REP(j,N){
	FOR(u,1,N+1){
	  int res = 0;
	  REP(i,3){
		int tmp = INF;
		for(int to: G_[u][i])
		  tmp = min(tmp, dp[to]+1);
		res = max(res, tmp);
	  }
	  dp[u] = min(dp[u], res);
	}
  }
  int ans = dp[1];
  if(ans >= INF)
	cout << "IMPOSSIBLE" << endl;
  else
	cout << ans << endl;
  
  return 0;
}