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;
constexpr int inf = 0x3FFFFFFF;
int dist[15][15];
int dp[1 << 15][15];
void read_dist(int V, int E) {
  for (int i = 0; i != V; ++i) {
    for (int j = 0; j != V; ++j) {
      dist[i][j] = inf;
    }
  }
  while (E--) {
    int s, t, d;
    cin >> s >> t >> d;
    dist[s][t] = d;
  }
}
int TSP(int V);
void init_dp(int V);
vector<int> find_visited_vertex(int mask);
int main() {
  int V = 0;
  int E = 0;
  cin >> V >> E;
  read_dist(V, E);
  cout << TSP(V);
  return 0;
}
int TSP(int V) {
  init_dp(V);
  int all = 1 << V;
  for (int mask = 1; mask != all; ++mask) {
    auto vs = find_visited_vertex(mask);
    for (auto v : vs) {
      int prev_mask = mask ^ (1 << v);
      for (auto u : vs) {
        if (v == u) continue;
        dp[mask][v] = min(dp[mask][v], dp[prev_mask][u] + dist[u][v]);
      }
    }
  }
  int min_cost = dp[all - 1][V - 1];
  return (min_cost < inf) ? min_cost : -1;
}
void init_dp(int V) {
  for (int mask = 0; mask != 1 << V; ++mask) {
    for (int i = 0; i != V; ++i) {
      dp[mask][i] = inf;
    }
  }
  dp[0][V - 1] = 0;
  for (int i = 0; i != V - 1; ++i) dp[1 << i][i] = dist[V - 1][i];
}
vector<int> find_visited_vertex(int mask) {
  vector<int> vs;
  int idx = 0;
  while (mask) {
    if (mask & 1) vs.push_back(idx);
    ++idx;
    mask >>= 1;
  }
  return vs;
}
