using System;
using System.Collections.Generic;
using System.Linq;

class PriorityQueue<T> where T : IComparable<T> {
    private List<T> _buf = new List<T>();
    private IComparer<T> _comp;

    private void Swap(int a, int b) {
        T t = _buf[a];
        _buf[a] = _buf[b];
        _buf[b] = t;
    }

    private int Compare(T a, T b) {
        if (_comp == null) return a.CompareTo(b);
        return _comp.Compare(a, b);
    }

    public int Count { get { return _buf.Count; } }

    public PriorityQueue() {
    }

    public PriorityQueue(IComparer<T> comp) {
        _comp = comp;
    }

    public void Enqueue(T x) {
        _buf.Add(x);

        // shiftup
        int p = Count-1;
        while (p > 0) {
            int parent = (p - 1) / 2;
            if (Compare(_buf[parent], _buf[p]) <= 0)
                break;
            Swap(parent, p);
            p = parent;
        }
    }

    public T Dequeue() {
        if (Count == 0)
            throw new IndexOutOfRangeException();

        T ret = _buf[0];
        _buf[0] = _buf[Count-1];
        _buf.RemoveAt(Count-1);

        // shiftdown
        int p = 0;
        while (p < Count) {
            int c = p * 2 + 1; // ?????????
            if (c >= Count) break;

            if (c+1 < Count) { // c+1 ????????????
                if (Compare(_buf[c+1], _buf[c]) < 0) { // ??????????????????????°???????
                    c++;
                }
            }

            if (Compare(_buf[p], _buf[c]) <= 0)
                break;
            Swap(p, c);
            p = c;
        }

        return ret;
    }
}

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    struct D : IComparable<D> {
        public int node;
        public int visited;
        public int cost;
        public bool finished; // ??¨??????note????¨??????????

        public int CompareTo(D o) { return cost - o.cost; }
    }

    static int Calc_1(int start, int v, int[,] adj) {
        var q = new PriorityQueue<D>();
        q.Enqueue(new D { node = start, visited = (1 << start), cost = 0, finished = false });

        var memo = new int[v, (1 << v)];
        for (int i = 0; i < v; i++)
            for (int j = 0; j < (1 << v); j++)
                memo[i, j] = int.MaxValue;

        while (q.Count > 0) {
            D d = q.Dequeue();

            if (d.finished) return d.cost;

            if (d.visited == (1 << v)-1) {
                // ??¨???????????????????¨???????????????§???start ?????????
                if (adj[d.node, start] != -1) {
                    int cost = d.cost + adj[d.node, start];
                    q.Enqueue(new D { node = start, visited = d.visited, cost = cost, finished = true });
                }
                continue;
            }

            if (memo[d.node, d.visited] < d.cost) continue;
            memo[d.node, d.visited] = d.cost;

            for (int i = 0; i < v; i++) {
                if (adj[d.node, i] == -1) continue; // ????????????

                if ((d.visited & (1 << i)) > 0) continue; // ?¨??????????

                int vv = d.visited | (1 << i);
                int cost = d.cost + adj[d.node, i];
                q.Enqueue(new D { node = i, visited = vv, cost = cost, finished = d.finished });
            }
        }
        return int.MaxValue;
    }

    static int Calc(int v, int[,] adj) {
        for (int i = 0; i < v; i++) {
            int ret = Calc_1(i, v, adj);
            if (ret != int.MaxValue)
                return ret;
        }
        return -1;
    }

    static void Main() {
        var ve = ReadInts();
        int v = ve[0], e = ve[1];

        var adj = new int[v, v];
        for (int i = 0; i < v; i++)
            for (int j = 0; j < v; j++)
                adj[i, j] = -1;

        for (int i = 0; i < e; i++) {
            var std = ReadInts();
            adj[std[0], std[1]] = std[2];
        }
        Console.WriteLine(Calc(v, adj));
    }
}

Measured memory_bytes: 24916