Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
#include <bits/stdc++.h>
typedef long long LL;
#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)

using namespace std;
int main(void)
{
  int n,m,a,b,c;
  cin >> n >> m >> a >> b >> c;
  int step[64][64][128];
  REP(i,64) REP(j,64) REP(k,128) step[i][j][k]=0;
  REP(i,m){
    int u,v;
    cin >> u >> v;
    step[u][v][1]=1;
  }
  REP(k,100) REP(i,n+1) REP(j,n+1) REP(l,n+1){
    step[i][j][k+1]=max(step[i][j][k+1],step[i][l][k]*step[l][j][1]);
  }
  int turns[64];
  REP(i,64) turns[i]=1024;
  turns[n]=0;
  REP(st,100) REP(i,n+1){
    int at=1024,bt=1024,ct=1024;
    REP(j,n+1){
      if(step[i][j][a]) at=min(at,turns[j]+1);
      if(step[i][j][b]) bt=min(bt,turns[j]+1);
      if(step[i][j][c]) ct=min(ct,turns[j]+1);
    }
    turns[i]=min(turns[i],max(at,max(bt,ct)));
  }
  if(turns[1]>1000) cout << "IMPOSSIBLE" << endl;
  else cout << turns[1] << endl;
  return 0;

}