// Slower C++ solution:
#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

using namespace std;



#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define all(v) begin(v), end(v)

#define pb(a) push_back(a)

#define fr first

#define sc second

#define INF 2000000000

#define int long long int



#define X real()

#define Y imag()

#define EPS (1e-10)

#define EQ(a,b) (abs((a) - (b)) < EPS)

#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )

#define LE(n, m) ((n) < (m) + EPS)

#define LEQ(n, m) ((n) <= (m) + EPS)

#define GE(n, m) ((n) + EPS > (m))

#define GEQ(n, m) ((n) + EPS >= (m))



typedef vector<int> VI;

typedef vector<VI> MAT;

typedef pair<int, int> pii;

typedef long long ll;



typedef complex<double> P;

typedef pair<P, P> L;

typedef pair<P, double> C;



int dx[]={1, -1, 0, 0};

int dy[]={0, 0, 1, -1};

int const MOD = 1000000007;

ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}

int madd(int a, int b) {return (a + b) % MOD;}

int msub(int a, int b) {return (a - b + MOD) % MOD;}

int mmul(int a, int b) {return (a * b) % MOD;}

int minv(int a) {return mod_pow(a, MOD-2);}

int mdiv(int a, int b) {return mmul(a, minv(b));}



namespace std {

    bool operator<(const P& a, const P& b) {

        return a.X != b.X ? a.X < b.X : a.Y < b.Y;

    }

}



int V, E;

int dp[1 << 15][20];

signed main() {

    cin >> V >> E;

    vector< vector<pii> > G(V);

    rep(i,0,E) {

        int s, t, d; cin >> s >> t >> d;

        G[s].pb(pii(t, d));

    }

    memset(dp, 0, sizeof(dp));

    rep(i,0,(1<<V)) rep(j,0,V) dp[i][j] = INF;

    dp[0][0] = 0;



    rep(bit,0,1<<V) {

        rep(i,0,V) {

            rep(j,0,G[i].size()) {

                int to = G[i][j].fr, cost = G[i][j].sc;

                if(bit >> to & 1) continue;

                int nbit = bit | (1 << to);

                dp[nbit][to] = min(dp[nbit][to], dp[bit][i] + cost);

            }

        }

    }

    int ans = dp[(1<<V)-1][0];

    cout << (ans == INF ? -1 : ans) << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.43185592353193x):
// ?????¬???????????¬??????



#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <functional>

using namespace std;



#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define int long long int



template<typename T> void chmax(T &a, T b) {a = max(a, b);}

template<typename T> void chmin(T &a, T b) {a = min(a, b);}

template<typename T> void chadd(T &a, T b) {a = a + b;}



typedef pair<int, int> pii;

typedef long long ll;



int dx[] = {0, 0, 1, -1};

int dy[] = {1, -1, 0, 0};

constexpr ll INF = 1001001001001001LL;

constexpr ll MOD = 1000000007LL;



// (to, cost)

vector<pii> G[20];

int dp[1 << 15][15];



void solve() {

    int V, E; cin >> V >> E;

    rep(i,0,E) {

        int s, t, d; cin >> s >> t >> d;

        G[s].push_back(pii(t, d));

    }



    rep(i,0,1<<V) rep(j,0,V) dp[i][j] = INF;

    dp[0][0] = 0;

    rep(bit,0,1<<V) rep(i,0,V) {

        for(auto x : G[i]) {

            if(bit >> x.first & 1) continue;

            int nbit = bit | (1 << x.first);

            chmin(dp[nbit][x.first], dp[bit][i] + x.second);

        }

    }

    int ans = (dp[(1<<V)-1][0] == INF ? -1 : dp[(1<<V)-1][0]);

    cout << ans << endl;

}



signed main() {

    solve();

    return 0;

}