#include #include using namespace std; int N,M; int A[2525]; int a[5000],b[5000],c[5000]; long dist[2][2525]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>M; int now=0; for(int i=0;i>A[i]; dist[now][i]=-1e18; } for(int i=0;i>a[i]>>b[i]>>c[i]; a[i]--,b[i]--; } dist[now][0]=A[0]; for(int t=1;t<=3*N;t++) { int nxt=1-now; for(int i=0;i(long)-1e18) { dist[nxt][b[i]]=max(dist[nxt][b[i]],dist[now][a[i]]-c[i]+A[b[i]]); } bool fn=false; for(int i=0;i=2*N) { cout<<"inf\n"; return 0; } now=nxt; } cout<