Example

Input

3 3 1 2 4
1 2
2 3
3 1


Output

IMPOSSIBLE
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<limits>
#include<numeric>
#include<bitset>
#include<unordered_map>
#include<functional>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define Sort(a) sort(all(a))
#define Qsort(a,size) qsort(a,size,sizeof(*a),compare_int)
//#define DEBUG
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
bool compare_by_second(II a,II b) { return a.second!=b.second?a.second<b.second:a.first<b.first; }
bool compare_int(const void *a,const void *b) { return *(int *)a-*(int *)b; }

const int INF = 1e+9;
const int MAX_N = 50;
const int MAX_M = 2450;
const int MAX_ABC = 1e+2;

int n,m,a,b,c;
vector<int> pattern;
vector< vector<int> > adj;
int turn = 0;

void solve();

int main() {

  cin>>n>>m>>a>>b>>c;
  pattern.push_back(a);
  pattern.push_back(b);
  pattern.push_back(c);

  adj.resize(n+1);
  rep(i,0,m) {
    int tmp1,tmp2;
    cin>>tmp1>>tmp2;
    adj[tmp1].push_back(tmp2);
  }

#ifdef DEBUG
  rep(i,0,n+1) {
    rep(j,0,adj[i].size()) cout<<adj[i][j]<<" ";
    cout<<endl;
  }
#endif

  solve();

  return 0;
}

void solve() {
  unordered_map<int,int> target,add;
  unordered_map<int,int> um1,um2;
  target[n] = 0;
  bool flag;

  while(true) {
    rep(i,1,n) {
      if(target.find(i) == target.end()) {
        rep(j,0,3) {
          um1[i] = 0;
          rep(k,0,pattern[j]) {
            //探索
            for(auto itr = um1.begin();itr!=um1.end();++itr) {
              rep(k,0,adj[itr->first].size()) um2[adj[itr->first][k]] = 0;
            }

            //コピー
            um1.clear();
            um1 = um2;
            um2.clear();
          }

          flag = false;
          for(auto itr=um1.begin();itr!=um1.end();++itr) {
            if(target.find(itr->first)!=target.end()) flag = true;
          }
          um1.clear();
          if(!flag) goto EXIT;

        }

        add[i] = 0;

      }
      EXIT: ;
    }

    turn++;
    if(add.empty()) { cout<<"IMPOSSIBLE"<<endl; return ; }
    if(add.find(1)!=add.end()) { cout<<turn<<endl; return ; }
    for(auto itr = add.begin();itr!=add.end();++itr) target[itr->first] = 0;
    add.clear();
  }

  return ;
}

