#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//#include "MyMath.h"
//#include "DataStructure.h"
#include <map>
#include <set>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#include <math.h>
#include <string.h>
using namespace std;
const int num = 15, num1 = 10000000;
typedef long long int ll;
typedef pair<int, int> p;
const int INF = 20000000;
int dp[1 << num][num], m[num][num];
int n, e;
int solve(int s, int v) {
	if (s == (1 << n) - 1 && v == 0) {
		return dp[s][v] = 0;
	}
	if (dp[s][v] >= 0)
		return dp[s][v];
	int res = INF;
	for (int t = 0; t < n; t++)
		if (!(s >> t & 1))
			res = min(res, m[v][t] + solve(s | 1 << t, t));
	return dp[s][v] = res;
}
int main() {
	cin >> n >> e;
	fill(m[0], m[num], INF);
	fill(dp[0], dp[1 << num], -1);
	for (int i = 0; i < e; i++) {
		int  s, t, u;
		cin >> s >> t >> u;
		m[s][t] = u;
	}
	if (solve(0, 0) >= INF)
		cout << -1 << endl;
	else cout << solve(0, 0) << endl;
	return 0;
}