Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
using vll=vevtor<ll>;

vll matmul(vll a, vvi b){
	int n=a.size();
	vll d(n,0);
	vll r(n,vi(n,0));
	rep(i,n)rep(j,n){
		d[j]|=b[j]&(1<<(n-i-1));
	}
	rep(i,n)rep(j,n){
		r[i][j]=!!(c[i]&d[j]);
	}
	return r;
}

vector<vll> memo(101);
vll matpow(vll a,int p){
	if(memo[p].size()==0)
		memo[p]=(p&1)?matmul(matpow(a,p-1),a):matmul(matpow(a,p/2),matpow(a,p/2));
	return memo[p];
}

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vll z(n,0), e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1]|=1<<(n-q);
		}
		fill(all(memo),vll());
		memo[1]=e;

		vector<vll> d(3);
		rep(p,3) d[p]=matpow(e,a[p]);
		
		vi g(n,0), ng(n,0);
		g[n-1]=1;
		rep(t,1000){
			bool next=0;
			fill(all(ng),0);
			rep(i,n) if(!g[i]){
				bool ok=1,r;
				rep(p,3) [&]{r=0; rep(j,n) r|=(g[j]&!!(d[p][i]&(1<<(n-j-1)))); ok&=r;}();
				if(ok) ng[i]=next=1;
			}
			if(!next){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng[0]){
				cout<<t+1<<endl;
				break;
			}
			rep(i,n)g[i]|=ng[i];
		}
	}
	return 0;
}



Compiler output:
a.cc:8:11: error: 'vevtor' does not name a type
    8 | using vll=vevtor<ll>;
      |           ^~~~~~
a.cc:10:1: error: 'vll' does not name a type; did you mean 'll'?
   10 | vll matmul(vll a, vvi b){
      | ^~~
      | ll
a.cc:23:8: error: 'vll' was not declared in this scope; did you mean 'll'?
   23 | vector<vll> memo(101);
      |        ^~~
      |        ll
a.cc:23:11: error: template argument 1 is invalid
   23 | vector<vll> memo(101);
      |           ^
a.cc:23:11: error: template argument 2 is invalid
a.cc:24:1: error: 'vll' does not name a type; did you mean 'll'?
   24 | vll matpow(vll a,int p){
      | ^~~
      | ll
a.cc: In function 'int main()':
a.cc:33:17: error: 'vll' was not declared in this scope; did you mean 'll'?
   33 |                 vll z(n,0), e=z;
      |                 ^~~
      |                 ll
a.cc:36:25: error: 'e' was not declared in this scope
   36 |                         e[p-1]|=1<<(n-q);
      |                         ^
a.cc:7:18: error: request for member 'begin' in 'memo', which is of non-class type 'int'
    7 | #define all(a) a.begin(),a.end()
      |                  ^~~~~
a.cc:38:22: note: in expansion of macro 'all'
   38 |                 fill(all(memo),vll());
      |                      ^~~
a.cc:7:28: error: request for member 'end' in 'memo', which is of non-class type 'int'
    7 | #define all(a) a.begin(),a.end()
      |                            ^~~
a.cc:38:22: note: in expansion of macro 'all'
   38 |                 fill(all(memo),vll());
      |                      ^~~
a.cc:39:21: error: invalid types 'int[int]' for array subscript
   39 |                 memo[1]=e;
      |                     ^
a.cc:39:25: error: 'e' was not declared in this scope
   39 |                 memo[1]=e;
      |                         ^
a.cc:41:27: error: template argument 2 is invalid
   41 |                 vector<vll> d(3);
      |                           ^
a.cc:42:27: error: invalid types 'int[int]' for array subscript
   42 |                 rep(p,3) d[p]=matpow(e,a[p]);
      |                           ^
a.cc:42:31: error: 'matpow' was not declared in this scope
   42 |                 rep(p,3) d[p]=matpow(e,a[p]);
      |                               ^~~~~~
a.cc: In lambda function:
a.cc:51:73: error: invalid types 'int[int]' for array subscript
   51 |                                 rep(p,3) [&]{r=0; rep(j,n) r|=(g[j]&!!(d[p][i]&(1<<(n-j-1)))); ok&=r;}();
      |                                                                         ^