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;
/*
dist[a] + w >= dist[b]

a ??? b ????????????:
dist[b] + 0 >= dist[a]

d ??????????????\???:
dist[b] - d >= dist[a]

d ??????????????\???:
dist[a] + d >= dist[b]
*/

const int INF = 1 << 28;

struct Edge {
	int src, dst, cost;
	Edge(){}
	Edge(int src, int dst, int cost): src(src), dst(dst), cost(cost){}
};

int n, c;
vector<Edge> es;
vector<int> any;
int dist[100][100];

int calc()
{
	fill_n(*dist, 100 * 100, INF);
	for (int i = 0; i < 100; i++) dist[i][i] = 0;
	for (auto &e : es) dist[e.src][e.dst] = min(dist[e.src][e.dst], e.cost);
	
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	for (int i = 0; i < n; i++) if (dist[i][i] < 0) return -1;
	int res = 0;
	for (int i = 0; i < n; i++) res = max(res, dist[0][i]);
	
	return res;
}

int main()
{
	scanf("%d %d", &n, &c);
	for (int i = 0; i < c; i++){
		int a, b, d;
		char o, s;
		
		scanf("%d", &a); --a;
		scanf("%c", &o);
		if (o != '*') scanf("%*c");
		else any.push_back(i);
		scanf("%d%c%d", &b, &s, &d); --b;
		
		if (o == '>') swap(a, b);
		es.push_back(Edge(b, a, 0));
		if (s == '+') es.push_back(Edge(b, a, -d));
		else es.push_back(Edge(a, b, d));
	}
	for (int i = 1; i < n; i++){
		es.push_back(Edge(i, 0, 0));
	}
	
	//for (auto e : es) printf("%d -> %d %d\n", e.src, e.dst, e.cost);
	
	int res = -1;
	for (int i = 0; i < (1 << any.size()); i++){
		for (int j = 0; j < any.size(); j++){
			if (i & (1 << j)){
				swap(es[any[j] * 2].src, es[any[j] * 2].dst);
				swap(es[any[j] * 2 + 1].src, es[any[j] * 2 + 1].dst);
			}
		}
		res = max(res, calc());
		for (int j = 0; j < any.size(); j++){
			if (i & (1 << j)){
				swap(es[any[j] * 2].src, es[any[j] * 2].dst);
				swap(es[any[j] * 2 + 1].src, es[any[j] * 2 + 1].dst);
			}
		}
	}
	if (res == INF) puts("inf");
	else printf("%d\n", res);
}