#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge {ll s,t,d;};
typedef vector<vector<Edge>> Graph;

int main(){
  ll V,E; cin>>V>>E;
  Graph G(V);
  REP(i,E) {Edge e; cin>>e.s>>e.t>>e.d; G[e.t].PB(e);}
  vvi dist((1ll<<V),vi(V,INF));
  dist[1][0]=0;

  FOR(i,2,(1ll<<V)) REP(j,V) {
    if((1ll<<j)&i) for(Edge e:G[j]) dist[i][j]=min(dist[i][j],dist[(1ll<<j)^i][e.s]+e.d);
  }

  ll ans=INF;
  for(Edge e:G[0]) ans=min(ans,dist[(1ll<<V)-1][e.s]+e.d);
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
}