Problem: Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University decided to predict the maximum distance of the procession. As a result of the preliminary survey, we know the following.

* The matrix is ​​lined with N people, each numbered from 1 to N.
* For each pair of C high school students (ai, bi), there are two types of restrictions:
* The first constraint is on the order and is one of the following:
ai must be ahead of bi or in the same position
ai must line up after or in the same position as bi
ai can be before, in the same position, or after bi

* The second constraint is on distance and is one of the following:
ai and bi must be at least di meters apart
ai and bi must line up within di meters




We also know that multiple people can be lined up at the same distance from the beginning, and that the number 1 person is always at the beginning of the procession.

Create a program to find the distance when the matrix that satisfies all the given C constraints is arranged so that the distance from the beginning to the end is the maximum. However, output inf if it can be separated indefinitely, and -1 if it is not possible to arrange in a way that satisfies the constraint.



input

The input is given in the following format.


N C
constraint1
constraint2
::
constraintC


The number of high school students in the queue on the first line N (2 ≤ N ≤ 100) and the number of constraints C (0 ≤ C ≤ 200) are given. Each constraint constrainti is given in the following C line in the following format.


aioibisidi


The constraint does not include spaces. The meanings of ai, oi, bi, si and di are shown below.

* ai and bi (1 ≤ ai, bi ≤ N and ai ≠ bi) are high school student numbers, and di is an integer representing the distance (0 ≤ d ≤ 10000).
* oi is a string of <=,> =, * that specifies the order constraint, and if <=, "ai must precede bi or be in the same position",> = In the case of, "ai must be after bi or in the same position", and in the case of *, it means that "ai can be before, in the same position, or after bi". However, no more than 7 constraints with oi as * can be given.
* si is the + or-character that specifies the distance constraint, for + "ai and bi must be at least di meters apart", for-"ai and bi must be within di meters" It means that.



However, it is assumed that multiple constraints are not given to a pair.

output

The distance from the beginning to the end is output on one line.

Example

Input

3 2
1


Output

3

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;

template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {  
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]) return vector< T >();
  }
  return dist;
}

pair<int, int> calc_bd(string s, int j) {
  int b = 0, d = 0;
  while ( isdigit(s[j]) ) {
    b *= 10;
    b += s[j]-'0';
    j++;
  }
  int sign = (s[j] == '+') ? 1 : -1;
  j++;
  while ( isdigit(s[j]) ) {
    d *= 10;
    d += s[j]-'0';
    j++;
  }
  return {b, sign*d};  
}

using t3 = tuple<int, int, int>;
const int INF = 1e9;

signed main() {  
  int N, C;
  cin >> N >> C;

  Edges<int> es;
  vector<t3> asta;     
  for ( int i = 0; i < C; i++ ) {
    string s;
    cin >> s;
    int j = 0;
    int a = 0, b = 0, d = 0;
    pair<int, int> p;
    
    while ( isdigit(s[j]) ) {
      a *= 10;
      a += s[j]-'0';
      j++;      
    }
    if ( s[j] == '*' ) {
      j++;
      p = calc_bd(s, j);
      b = p.first;
      d = p.second;
      a--; b--;
      asta.emplace_back(t3(a, b, d));      
    } else {
      char c = s[j];      
      j += 2;      
      p = calc_bd(s, j);
      b = p.first;
      d = p.second;
      a--; b--;
      if ( c == '<' ) {
	es.emplace_back(b, a, 0);	
	if ( d > 0 ) es.emplace_back(b, a, -d);	
	else es.emplace_back(a, b, -d);	
      } else {
	es.emplace_back(a, b, 0);	
	if ( d > 0 ) es.emplace_back(a, b, -d);	
	else es.emplace_back(b, a, -d);	
      }
    }
  }

  int sz = asta.size();
  // cout << sz << endl;
  int ans = -1;  
  bool flag2 = false;
  for ( int i = 0; i < (1<<sz); i++ ) {
    Edges<int> tmp = es;
    for ( int j = 0; j < sz; j++ ) {
      int a = get<0>(asta[j]), b = get<1>(asta[j]), d = get<2>(asta[j]);
      // cout << a << " " << b << " " << d << endl;
      if ( i & (1<<j) ) {
	tmp.emplace_back(b, a, 0);	
	if ( d > 0 ) tmp.emplace_back(b, a, -d);	
	else  tmp.emplace_back(a, b, -d);	
      } else {
	tmp.emplace_back(a, b, 0);	
	if ( d > 0 ) tmp.emplace_back(a, b, -d);	
	else tmp.emplace_back(b, a, -d);	
      }
    }

    auto dists = bellman_ford(tmp, N, 0);
    if ( dists.empty() || *min_element(begin(dists), end(dists)) < 0 ) continue;
    flag2 = true;
    // cout << *max_element(begin(dists), end(dists)) << endl;
    ans = max(ans, *max_element(begin(dists), end(dists)));      
  }
  
  if ( ans == numeric_limits<int>::max() ) puts("inf");  
  else cout << ans << endl;  
  
  return 0;
}