#include <bits/stdc++.h>
using namespace std;
int inf = 1000000000;
int a, s, d[88][88][88][2], f, g, h, j, k, l, i, n, m, pas = inf;
vector<pair<int, int> > v[88];
int main() {
  cin >> n >> m >> k;
  for (i = 0; i < k; i++) {
    cin >> a >> s >> h;
    v[a].push_back({s, h});
  }
  for (i = n - 1; i >= 0; i--) {
    for (a = 1; a <= n - i; a++) {
      for (j = 1; j <= m; j++) {
        d[a][i + a][j][0] = inf;
        d[a][i + a][j][1] = inf;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    d[1][i][1][1] = 0;
    d[i][n][1][0] = 0;
  }
  for (i = n - 1; i >= 0; i--) {
    for (a = 1; a <= n - i; a++) {
      for (j = 1; j < m; j++) {
        if (d[a][i + a][j][0] != inf) {
          for (auto it : v[a]) {
            if (it.first <= a || it.first > i + a) continue;
            d[a + 1][it.first][j + 1][1] = min(d[a + 1][it.first][j + 1][1],
                                               d[a][i + a][j][0] + it.second);
            d[it.first][i + a][j + 1][0] = min(d[it.first][i + a][j + 1][0],
                                               d[a][i + a][j][0] + it.second);
          }
        }
        if (d[a][i + a][j][1] != inf) {
          for (auto it : v[i + a]) {
            if (it.first < a || it.first >= i + a) continue;
            d[a][it.first][j + 1][1] =
                min(d[a][it.first][j + 1][1], d[a][i + a][j][1] + it.second);
            d[it.first][i + a - 1][j + 1][0] =
                min(d[it.first][i + a - 1][j + 1][0],
                    d[a][i + a][j][1] + it.second);
          }
        }
      }
      pas = min(pas, d[a][i + a][m][0]);
      pas = min(pas, d[a][i + a][m][1]);
    }
  }
  if (pas == inf)
    cout << -1;
  else
    cout << pas;
}
