import std.stdio, std.string, std.conv, std.algorithm, std.array;

enum VMAX = 15 + 1;
enum INF = 1 << 29;

int[VMAX][VMAX] table;
int[1<<VMAX][VMAX] dp;
int V, E;

int solve(int S, int v) {
    if ( dp[v][S] >= 0 ) {
        return dp[v][S];
    }

    if ( S == (1 << V) - 1 && v == 0 ) {
        return dp[v][S] = 0;
    }

    int tmp = INF;
    for( int u=0; u<V; ++u ) {
        if ( !( S >> u & 1 ) ) {
            // goto u from v
            tmp = min(tmp, solve(S | 1 << u, u) + table[u][v]);
        }
    }

    return dp[v][S] = tmp;
}

void main() {
    fill(table[0..$][0..$], INF);

    auto ss = readln.chomp.split(" ").map!(to!int).array;
    V = ss[0];
    E = ss[1];

    for( int i=0; i<E; ++i ) {
        auto sss = readln.chomp.split(" ").map!(to!int).array;
        immutable start = sss[0], end = sss[1], cost = sss[2];
        table[end][start] = cost;
    }


    fill(dp[0..$][0..$], -1);

    immutable ans = solve(0, 0);
    (ans == INF ? -1 : ans).writeln;
}