// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; scanf("%d%d", &N, &M);

    vector< vector< pair<int, int> > > G(N);
    vector< tuple<int, int, int, int> > later;

    auto add_edge = [&]() -> void {
        string s; cin >> s;
        int u = 0, v = 0, d = 0, t1 = -1, t2 = -1, ptr = 0;
        while(isdigit(s[ptr])) u = (u * 10 + (s[ptr++] - '0'));
        if(s.substr(ptr, 1) == "*") t1 = 1, ptr += 1;
        else if(s.substr(ptr, 2) == "<=") t1 = 2, ptr += 2;
        else if(s.substr(ptr, 2) == ">=") t1 = 3, ptr += 2;
        while(isdigit(s[ptr])) v = (v * 10 + (s[ptr++] - '0'));
        if(s.substr(ptr, 1) == "+") t2 = 1, ptr += 1;
        else if(s.substr(ptr, 1) == "-") t2 = 2, ptr += 1;
        while(isdigit(s[ptr])) d = (d * 10 + (s[ptr++] - '0'));

        u--; v--;
        if(t1 == 3) swap(u, v);
        if(t1 != 1) {
            G[v].emplace_back(u, 0);
            if(t2 == 1) G[v].emplace_back(u, -d);
            else G[u].emplace_back(v, +d);
        }
        else later.emplace_back(u, v, t2, d);
    };

    for(int i=0; i<M; i++) add_edge();
    for(int i=1; i<N; i++) G[i].emplace_back(0, 0);

    int K = later.size();
    ll ans = -1;
    for(int bit=0; bit<(1<<K); bit++) {
        auto H = G;
        for(size_t i=0; i<K; i++) {
            int u, v, t, d; tie(u, v, t, d) = later[i];
            if(bit >> i & 1) swap(u, v);
            if(t == 1) {
                H[v].emplace_back(u, -d);
            }
            else {
                H[v].emplace_back(u, 0);
                H[u].emplace_back(v, +d);
            }
        }
        
        vector<ll> dist(N, LONGINF);
        dist[0] = 0;
        for(int iter=0; iter<2*N; iter++) {
            for(int i=0; i<N; i++) {
                for(auto e : H[i]) {
                    int j, c; tie(j, c) = e;
                    if(dist[j] > dist[i] + c) {
                        dist[j] = dist[i] + c;
                        if(iter + 1 >= N) dist[j] = -LONGINF;
                    }
                }
            }
        }

        vector<bool> reached(N);
        reached[0] = true;
        queue<int> que;
        que.emplace(0);
        while(que.size()) {
            int cur = que.front(); que.pop();
            for(auto e : H[cur]) {
                int to = e.first;
                if(!reached[to]) {
                    reached[to] = true;
                    que.emplace(to);
                }
            }
        }
        
        bool nega = false; ll max_val = 0;
        for(int i=0; i<N; i++) {
            nega |= dist[i] < 0;
            chmax(max_val, (reached[i] ? dist[i] : LONGINF));
            // fprintf(stderr, "%lld ", dist[i]);
        }
        // fprintf(stderr, "\n");

        if(!nega) chmax(ans, max_val);
    }

    if(ans >= LONGINF) puts("inf");
    else printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 3352