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>
class Route {
 public:
  Route(const int &n = 0) : state(n){};
  bool filled() const { return state == ((1 << size) - 1); }
  Route remove(const int &n) const { return Route(state & (-1 - (1 << n))); }
  Route add(const int &n) const { return Route(state | (1 << n)); }
  bool include(const int &n) const { return (state & (1 << n)) != 0; }
  bool operator<(const Route &other) const { return state < other.state; }
  bool operator>(const Route &other) const { return other.state < state; }
  bool operator==(const Route &other) const { return state == other.state; }
  bool operator<=(const Route &other) const {
    return *this < (other) || *this == (other);
  }
  bool operator>=(const Route &other) const {
    return *this > (other) || *this == (other);
  }
  int to_i() const { return state; }
  void inspect() const;
  void inspect(int) const;
  static int size;

 private:
  int state;
};
void Route::inspect() const {
  inspect(state);
  std::cout << std::endl;
}
void Route::inspect(int s) const {
  if (s > 1) {
    inspect(s / 2);
    std::cout << s % 2;
  } else {
    std::cout << s;
  }
}
class Edge {
 public:
  Edge(const int &f = 0, const int &t = 0, const int &w = 0)
      : from(f), to(t), weight(w){};
  bool operator<(const Edge &other) const { return (to < other.to); }
  int from, to, weight;
};
int dp(std::vector<std::vector<int>> &memo,
       std::vector<std::vector<Edge>> &edge, const Route &route,
       const int &vertex) {
  if (memo.at(route.to_i()).at(vertex) != -1) {
    return memo.at(route.to_i()).at(vertex);
  } else if (route.filled() && vertex == 0) {
    return memo.at(route.to_i()).at(vertex) = 0;
  } else {
    int min = 15000;
    for (auto &e : edge.at(vertex)) {
      if (!route.include(e.to)) {
        auto temp = dp(memo, edge, route.add(e.to), e.to) + e.weight;
        if (min > temp) {
          min = temp;
        }
      }
    }
    return memo.at(route.to_i()).at(vertex) = min;
  }
}
int Route::size = 30;
int main() {
  int v, e;
  std::cin >> v >> e;
  Route::size = v;
  std::vector<std::vector<int>> vector((1 << v), std::vector<int>(v, -1));
  std::vector<std::vector<Edge>> edges(v, std::vector<Edge>(0));
  for (auto i = 0; i < e; ++i) {
    int s, t, d;
    std::cin >> s >> t >> d;
    edges.at(s).push_back(Edge(s, t, d));
  }
  if (dp(vector, edges, Route(0), 0) > 15000) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << dp(vector, edges, Route(0), 0) << std::endl;
  }
  return 0;
}
