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;
const int infty = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> cmngrh;
  vector<pair<char, pair<int, pair<int, int>>>> addgrh;
  for (int i = 1; i < n; i++) {
    cmngrh.push_back({0, {i, 0}});
  }
  int ans = -1;
  for (int i = 0; i < m; i++) {
    string qtx;
    cin >> qtx;
    int a(0), b(0), d(0);
    char ord('$'), inq('$');
    int phase = 0;
    for (int j = 0; j < qtx.length(); j++) {
      if (qtx[j] - '0' < 0 || 10 <= qtx[j] - '0') {
        if (!(phase & 1)) {
          phase++;
        }
        char* it;
        switch (phase) {
          case 1:
            it = &ord;
            break;
          case 3:
            it = &inq;
            break;
          default:
            break;
        }
        if (*it == '$') {
          *it = qtx[j];
        }
      } else {
        if (phase & 1) {
          phase++;
        }
        int* it;
        switch (phase) {
          case 0:
            it = &a;
            break;
          case 2:
            it = &b;
            break;
          case 4:
            it = &d;
            break;
          default:
            break;
        }
        *it *= 10;
        *it += qtx[j] - '0';
      }
    }
    a--;
    b--;
    if (ord == '*') {
      addgrh.push_back({inq, {d, {a, b}}});
      continue;
    }
    if (ord == '>') {
      swap(a, b);
    }
    if (ord != '*') {
      cmngrh.push_back({0, {b, a}});
    }
    if (inq == '+') {
      swap(a, b);
      d *= -1;
    }
    cmngrh.push_back({d, {a, b}});
  }
  for (int bs = 0; bs < 1 << addgrh.size(); bs++) {
    vector<pair<int, pair<int, int>>> grh = cmngrh;
    for (int i = 0; i < addgrh.size(); i++) {
      auto crr = addgrh[i];
      char inq = crr.first;
      int d = crr.second.first;
      int s = crr.second.second.first;
      int t = crr.second.second.second;
      if (bs & (1 << i)) {
        swap(s, t);
      }
      grh.push_back({0, {t, s}});
      if (inq == '+') {
        swap(s, t);
        d *= -1;
      }
      grh.push_back({d, {s, t}});
    }
    int diam = 0;
    vector<int> dst(n, infty);
    dst[0] = 0;
    for (int i = 0; i < n; i++) {
      for (auto e : grh) {
        int d = e.first;
        int s = e.second.first;
        int t = e.second.second;
        if (dst[s] != infty) {
          dst[t] = min(dst[t], dst[s] + d);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      diam = max(diam, dst[i]);
    }
    for (int i = 0; i < n; i++) {
      for (auto e : grh) {
        int d = e.first;
        int s = e.second.first;
        int t = e.second.second;
        if (dst[s] != infty && dst[t] > dst[s] + d) {
          diam = -1;
        }
      }
    }
    ans = max(ans, diam);
  }
  if (ans == infty) {
    cout << "inf" << '\n';
  } else {
    cout << ans << '\n';
  }
  return 0;
}