import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N, X, M; scanf("%d %d %d\n", &N, &X, &M);
    struct T {
       int l, r, s;
    } 
    auto P = new T[M];
    foreach (i; 0 .. M) {
        int L, R, S;
        scanf("%d %d %d\n", &L, &R, &S);
        L--; R--;
        P[i] = T(L, R, S);
    }

    auto res = new int[N];

    int F() {
        auto sum = new int[N + 1];
        sum[0] = 0;
        foreach (i; 1 .. N + 1) {
            sum[i] = sum[i - 1] + res[i - 1];
        }
        foreach (i; 0 .. M) {
            if (sum[ P[i].r + 1 ] - sum[ P[i].l ] != P[i].s) return -1;
        }
        return sum[N];
    }

    int Ans = -1;
    int[] AnsA;
    void dfs(int x) {
        if (x == N) {
            int f = F;
            if (Ans < f) {
                Ans = f;
                AnsA = res.dup;
            }
            return;
        }
        for (int i = 0; i <= X; i++) {
            res[x] = i;
            dfs(x + 1);
        }
    }

    dfs(0);
    if (Ans < 0) {
        writeln(-1);
    } else {
        writefln("%(%s %)", AnsA);
    }
}