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
#include<bits/stdc++.h>

using namespace std;

struct edge
{
  int u, v, cost;

  edge(int u, int v, int c) : u(u), v(v), cost(c) {}
};

const int INF = 1 << 30;

int main()
{
  int N, C;
  int A[200], O[200], B[200], S[200], D[200];

  auto bellman_ford = [&]()
  {
    vector< edge > edges;
    vector< int > v(N, INF), lastupdate(N, -1);
    v[0] = 0, lastupdate[0] = 0;

    for(int i = 0; i < C; i++) {
      if(O[i] == 1) swap(A[i], B[i]);
      edges.emplace_back(B[i], A[i], 0);
      if(S[i] == 0) edges.emplace_back(B[i], A[i], -D[i]);
      else edges.emplace_back(A[i], B[i], D[i]);
      if(O[i] == 1) swap(A[i], B[i]);
    }

    for(int i = 0; i <= N; i++) {
      for(auto &e : edges) {
        if(v[e.u] + e.cost < v[e.v]) {
          v[e.v] = v[e.u] + e.cost;
          lastupdate[e.v] = i;
        }
      }
    }

    int ret = 0;
    for(int i = 0; i < N; i++) {
      if(lastupdate[i] == N) return (-1);
      if(v[i] < 0) return (-1);
      ret = max(ret, v[i]);
    }
    return (ret);
  };

  cin >> N >> C;
  vector< int > undefined;
  for(int i = 0; i < C; i++) {
    string str;
    cin >> str;
    int tail = 0, a = 0, b = 0, o, s, d = 0;
    while(isdigit(str[tail])) a = a * 10 + str[tail++] - '0';
    if(str[tail] == '*') o = 2;
    else if(str[tail] == '<') o = 0, ++tail;
    else o = 1, ++tail;
    ++tail;
    while(isdigit(str[tail])) b = b * 10 + str[tail++] - '0';
    if(str[tail] == '+') s = 0;
    else s = 1;
    ++tail;
    while(tail < str.size()) d = d * 10 + str[tail++] - '0';
    A[i] = --a, B[i] = --b, O[i] = o, S[i] = s, D[i] = d;
    if(o == 2) undefined.push_back(i);
  }
  int ret = -1;

  for(int i = 0; i < (1 << undefined.size()); i++) {
    for(int j = 0; j < undefined.size(); j++) O[undefined[j]] = (i >> j) & 1;
    ret = max(ret, bellman_ford());
  }

  if(ret >= INF) cout << "inf" << endl;
  else cout << ret << endl;
}