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:
// AOJ 0304 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0304)
#include<cctype>
#include<iostream>
#include<string>
#include<vector>
#include<limits>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 210, MAX_C = 210, INF = std::numeric_limits<int>::max()>>2;

struct edge
{
	int from, to, cost;

	edge( int from, int to, int cost )
	:	from(from), to(to), cost(cost)
	{}
};

struct Dat
{
	int a, b, d;
	bool pm;

	Dat( int a, int b, int d, bool pm )
	:	a(a), b(b), d(d), pm(pm)
	{}
};

int N, C;
std::string cst[MAX_C];
std::vector<edge> es;
std::vector<Dat> dats;
int d[MAX_N];

int read( int &p, const std::string &s )
{
	int ret = 0;

	while( p < s.size() && isdigit(s[p]) )
		ret *= 10, ret += s[p++]-'0';

	return ret;
}

int bellmanFord()
{
	std::fill( d, d+N, INF );
	d[0] = 0;
	
	rep( j, N )
	{
		rep( i, es.size() ) if( d[es[i].from] != INF && d[es[i].from]+es[i].cost < d[es[i].to] )
		{
			d[es[i].to] = d[es[i].from]+es[i].cost;

			if( j == N-1 )
				return -INF;
		}
	}

	int ret = -INF;
	rep( j, N )
		ret = std::max( ret, d[j] );

	return ret;
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	std::cin >> N >> C;
	rep( i, C )
	{
		std::cin >> cst[i];

		int p = 0, t = 0, d = 0;
		bool pm;

		int a = read( p, cst[i] );
			
		if( cst[i][p] == '<' )
			t = 0, p += 2;
		else if( cst[i][p] == '>' )
			t = 1, p += 2;
		else if( cst[i][p] == '*' )
			t = 2, ++p;

		int b = read( p, cst[i] );
		pm = cst[i][p++]=='+';
		d = read( p, cst[i] );

		--a; --b;

		es.push_back( edge( a, 0, 0 ) );
		es.push_back( edge( b, 0, 0 ) );
	
		if( !t )
		{
			es.push_back( edge( b, a, 0 ) );
			es.push_back( pm?edge( b, a, -d ):edge( a, b, d ) );
		}
		else if( t == 1 )
		{
			es.push_back( edge( a, b, 0 ) );
			es.push_back( pm?edge( a, b, -d ):edge( b, a, d ) );
		}
		else if( t == 2 )
			dats.push_back( Dat( a, b, d, pm ) );
	}

	int ans = -INF;

	if( dats.empty() )
		ans = std::max( ans, bellmanFord() );

	rep( i, 1<<(dats.size()) )
	{
		rep( j, dats.size() )
		{
			if( i>>j&1 )
			{
				es.push_back( edge( dats[j].b, dats[j].a, 0 ) );
				es.push_back( dats[j].pm?edge( dats[j].b, dats[j].a, -dats[j].d ):edge( dats[j].a, dats[j].b, dats[j].d ) );
			}
			else
			{
				es.push_back( edge( dats[j].a, dats[j].b, 0 ) );
				es.push_back( dats[j].pm?edge( dats[j].a, dats[j].b, -dats[j].d ):edge( dats[j].b, dats[j].a, dats[j].d ) );
			}
		}

		 ans = std::max( ans, bellmanFord() );

		 rep( j, dats.size()*2 )
			es.pop_back();
	}

	if( ans == INF )
		std::cout << "inf" << std::endl;
	else
		std::cout << (ans>=0?ans:-1) << std::endl;

	return 0;
}