For a given weighted directed graph G(V, E), find the distance of the shortest route that meets the following criteria:

* It is a closed cycle where it ends at the same point it starts.
* It visits each vertex exactly once.

Constraints

* 2 ≤ |V| ≤ 15
* 0 ≤ di ≤ 1,000
* There are no multiedge

Input


|V| |E|
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1


|V| is the number of vertices and |E| is the number of edges in the graph. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively.

si and ti represent source and target vertices of i-th edge (directed) and di represents the distance between si and ti (the i-th edge).

Output

Print the shortest distance in a line. If there is no solution, print -1.

Examples

Input

4 6
0 1 2
1 2 3
1 3 9
2 0 1
2 3 6
3 2 4


Output

16


Input

3 3
0 1 1
1 2 1
0 2 1


Output

-1
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const ll MAXV = 17;

ll dist[MAXV][MAXV]{};
ll dp[(1ll<<MAXV)][MAXV]{};

int main(int argc, char **argv)
{
	ll V, E;
	cin >> V >> E;
	REP(i, V)REP(j, V) dist[i][j] = INF;
	REP(i, E)
	{
		ll a, b, d; cin >> a >> b >> d;;
		dist[a][b] = d;
	}

	ll SMAX = (1ll<<V);
	REP(bits, SMAX) REP(v, V) dp[bits][v] = INF;
	dp[0][0] = 0;

	REP(bits, SMAX)
	{
		REP(s, V)
		{
			REP(g, V)
			{
				// s to g
				if (!(bits & (1ll<<g)))
				{
					ll tmp = bits|(1ll<<g);
					dp[tmp][g] = min(dp[tmp][g],
									 dp[bits][s]+dist[s][g]);
				}
			}
		}
	}

	ll res = dp[SMAX-1][0];
	std::cout << (res == INF ? -1 : res)<< std::endl;
}

