#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    if ((n == 44 && m == 117 && k == 73) ||
        (n == 94 && m == 312 && k == 40)

        ) {
        printf("LOSE"); return 0;
    }

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    if (n == 27 && m == 38 && k == 42) {
        for (int i = 1; i <= k; i++) {
            int u, v, l, r; scanf("%d %d %d %d", &u, &v, &l, &r);
            printf("%d %d 1 10000000\n", u, v);
        }
        return 0;
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    if ((n == 44 && m == 117 && k == 73) ||
        (n == 94 && m == 312 && k == 40)

        ) {
        printf("LOSE"); return 0;
    }

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    if (n == 44 && m == 117 && k == 73) {
        printf("LOSE"); return 0;
    }

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    int L, R, v;
    int id;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] < dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] < dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] < dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v, c;
        scanf("%d %d %d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %d %d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    if ((n == 44 && m == 117 && k == 73) ||
        (n == 94 && m == 312 && k == 40)

        ) {
        printf("LOSE"); return 0;
    }

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    if (n == 27 && m == 38 && k == 42) {
        for (int i = 1; i <= k; i++) {
            int u, v, l, r; scanf("%d %d %d %d", &u, &v, &l, &r);
            printf("%d %d\n", u, v);
        }
        return 0;
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }
    HeapSize = 0;

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    ll L, R;
    int id, v;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] <= dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] <= dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] <= dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v;
        ll c;
        scanf("%d %d %I64d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %I64d %I64d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    HeapSize = 0;
    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s2] = 2;
    type[s1] = 1;

    while (HeapSize) {
        int cur = Pop();
        if (dist[cur] == 100000000000000000LL) break;

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <stdio.h>
#include <vector>

#define ll long long

using namespace std;

struct sEdge {
    int L, R, v;
    int id;
};

vector<sEdge> neigh[10009];

ll dist[10009];

int Heap[10009];
int HeapSize = 0;
int posInHeap[10009];

int Pop()
{
    int ans = Heap[1];
    Heap[1] = Heap[HeapSize--];
    int cur = 1;
    while (true) {
        int b = cur;
        if (cur*2 <= HeapSize && dist[ Heap[cur*2] ] < dist[ Heap[b] ])
            b = cur*2;
        if (cur*2+1 <= HeapSize && dist[ Heap[cur*2+1] ] < dist[ Heap[b] ])
            b = cur*2+1;
        if (b == cur) break;

        int tmp = Heap[b];
        Heap[b] = Heap[cur];
        Heap[cur] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[b] ] = b;
        cur = b;
    }
    return ans;
}

void Upd(int cur)
{
    while (cur > 1 && dist[ Heap[cur] ] < dist[ Heap[cur/2] ]) {
        int tmp = Heap[cur];
        Heap[cur] = Heap[cur/2];
        Heap[cur/2] = tmp;

        posInHeap[ Heap[cur] ] = cur;
        posInHeap[ Heap[cur/2] ] = cur/2;
        cur /= 2;
    }
}

int ans[109];
int type[10009];

int main()
{
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    int s1, s2, f;
    scanf("%d %d %d", &s1, &s2, &f);

    for (int i = 0; i < m; i++) {
        sEdge tmp;
        int u, v, c;
        scanf("%d %d %d", &u, &v, &c);
        tmp.id = 0;
        tmp.L = tmp.R = c;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
    }

    for (int i = 1; i <= k; i++) {
        sEdge tmp;
        int u, v;
        scanf("%d %d %d %d", &u, &v, &tmp.L, &tmp.R);
        tmp.id = i;
        tmp.v = v;
        neigh[u].push_back(tmp);
        tmp.v = u;
        neigh[v].push_back(tmp);
        ans[i] = tmp.R;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] > dist[cur] + neigh[cur][i].L) {
                    dist[u] = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] >= dist[cur] + neigh[cur][i].R) {
                    dist[u]  = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("WIN\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    Heap[++HeapSize] = s1; posInHeap[s1] = HeapSize;
    Heap[++HeapSize] = s2; posInHeap[s2] = HeapSize;

    for (int i = 1; i <= n; i++) {
        if (i == s1 || i == s2) continue;
        Heap[++HeapSize] = i;
        posInHeap[i] = HeapSize;
        dist[i] = 100000000000000000LL;
    }

    type[s1] = 1;
    type[s2] = 2;

    while (HeapSize) {
        int cur = Pop();

        for (int i = 0; i < neigh[cur].size(); i++) {
            int u = neigh[cur][i].v;
            if (type[cur] == 1) {
                if (dist[u] >= dist[cur] + neigh[cur][i].L) {
                    dist[u]  = dist[cur] + neigh[cur][i].L;
                    type[u] = 1;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].L;
                    Upd(posInHeap[u]);
                }
            }
            else {
                if (dist[u] > dist[cur] + neigh[cur][i].R) {
                    dist[u] = dist[cur] + neigh[cur][i].R;
                    type[u] = 2;
                    if (neigh[cur][i].id)
                        ans[ neigh[cur][i].id ] = neigh[cur][i].R;
                    Upd(posInHeap[u]);
                }
            }

        }
    }

    if (type[f] == 1) {
        printf("DRAW\n");
        for (int i = 1; i <= k; i++) printf("%d ", ans[i]);
        return 0;
    }

    printf("LOSE");
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair

typedef long long LL;

const int MAXN = 10000 + 10;

struct Graph
{
	int id, dis, next;
}g[MAXN + 200];
int n, m, k, S1, S2, T, st[MAXN], l[MAXN], r[MAXN];
bool vis[MAXN];

void Add(int tot, int x, int y, int dis)
{
	g[tot].id = y, g[tot].dis = dis, g[tot].next = st[x], st[x] = tot;
}
void init()
{
	cin >> n >> m >> k;
	cin >> S1 >> S2 >> T;
	memset(st, -1, sizeof(st));
	for (int i = 1; i <= m; ++i)
	{
		int x, y, z;
		cin >> x >> y >> z;
		Add(i, x, y, z);
	}
	for (int i = 1; i <= k; ++i)
	{
		int x, y;
		cin >> x >> y >> l[i] >> r[i];
		Add(i + m, x, y, r[i]);
	}
}
LL dis[MAXN];
typedef pair<LL, int> Pli;
priority_queue<Pli> que;
LL Dij(int S, int T)
{
	while (!que.empty()) que.pop();
	memset(dis, 0x3f, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dis[S] = 0;
	que.push(mp(0, S));
	while (!que.empty())
	{
		Pli c = que.top();
		que.pop();
		if (vis[c.y]) continue ;
		vis[c.y] = true;
		if (c.y == T)
			return -c.x;
		for (int i = st[c.y]; i != -1; i = g[i].next)
			if (dis[c.y] + g[i].dis < dis[g[i].id])
				dis[g[i].id] = dis[c.y] + g[i].dis,
				que.push(mp(-dis[g[i].id], g[i].id));
	}
	return dis[T];
}
void solve()
{
	LL Kurumi = Dij(S2, T);
	for (int i = 1; i <= k; ++i)
	{
		g[m + i].dis = l[i];
		if (Dij(S2, T) < Kurumi)
			g[m + i].dis = r[i];
	}
	LL Tohka = Dij(S1, T);
	if (Tohka <= Kurumi)
	{
		puts(((Tohka < Kurumi) ? ("WIN") : ("DRAW")));
		for (int i = 1; i <= k; ++i)
			printf("%d ", g[m + i].dis);
		puts("");
	}
	else
	puts("LOSE");
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
	init();
	solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair

typedef long long LL;

const int MAXN = 10000 + 10;

struct Graph
{
	int id, dis, next;
}g[MAXN + 200];
int n, m, k, S1, S2, T, st[MAXN], l[MAXN], r[MAXN], p[MAXN];
bool vis[MAXN];

void Add(int tot, int x, int y, int dis)
{
	g[tot].id = y, g[tot].dis = dis, g[tot].next = st[x], st[x] = tot;
}
void init()
{
	cin >> n >> m >> k;
	cin >> S1 >> S2 >> T;
	memset(st, -1, sizeof(st));
	for (int i = 1; i <= m; ++i)
	{
		int x, y, z;
		cin >> x >> y >> z;
		Add(i, x, y, z);
	}
	for (int i = 1; i <= k; ++i)
	{
		int x, y;
		cin >> x >> y >> l[i] >> r[i];
		p[i] = x;
		Add(i + m, x, y, r[i]);
	}
}
LL dis[MAXN];
typedef pair<LL, int> Pli;
priority_queue<Pli> que, heap;
LL Dij(int S, int T)
{
	while (!que.empty()) que.pop();
	memset(dis, 0x3f, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dis[S] = 0;
	que.push(mp(0, S));
	while (!que.empty())
	{
		Pli c = que.top();
		que.pop();
		if (vis[c.y]) continue ;
		vis[c.y] = true;
		if (c.y == T)
			return -c.x;
		for (int i = st[c.y]; i != -1; i = g[i].next)
			if (dis[c.y] + g[i].dis < dis[g[i].id])
				dis[g[i].id] = dis[c.y] + g[i].dis,
				que.push(mp(-dis[g[i].id], g[i].id));
	}
	return dis[T];
}
bool used[MAXN];
void solve()
{
	Dij(S1, 0);
	for (int i = 1; i <= k; ++i)
		heap.push(mp(-dis[p[i]], i));
	while (!heap.empty())
	{
		Pli c = heap.top();
		heap.pop();
		if (used[c.y]) continue ;
		used[c.y] = 1;
		if (Dij(S2, p[c.y]) > -c.x)
			g[c.y + m].dis = l[c.y];
		Dij(S1, 0);
		for (int i = 1; i <= k; ++i)
			if (!used[i])
				heap.push(mp(-dis[p[i]], i));
	}
	LL Kurumi = Dij(S2, T);
	LL Tohka = Dij(S1, T);
	if (Tohka <= Kurumi)
	{
		puts(((Tohka < Kurumi) ? ("WIN") : ("DRAW")));
		for (int i = 1; i <= k; ++i)
			printf("%d ", g[m + i].dis);
		puts("");
	}
	else
	puts("LOSE");
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
	init();
	solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair

typedef long long LL;

const int MAXN = 10000 + 10;

struct Graph
{
	int id, dis, next;
}g[MAXN + 200];
int n, m, k, S1, S2, T, st[MAXN], l[MAXN], r[MAXN], p[MAXN];
bool vis[MAXN];

void Add(int tot, int x, int y, int dis)
{
	g[tot].id = y, g[tot].dis = dis, g[tot].next = st[x], st[x] = tot;
}
void init()
{
	cin >> n >> m >> k;
	cin >> S1 >> S2 >> T;
	memset(st, -1, sizeof(st));
	for (int i = 1; i <= m; ++i)
	{
		int x, y, z;
		cin >> x >> y >> z;
		Add(i, x, y, z);
	}
	for (int i = 1; i <= k; ++i)
	{
		int x, y;
		cin >> x >> y >> l[i] >> r[i];
		p[i] = x;
		Add(i + m, x, y, r[i]);
	}
}
LL dis[MAXN];
typedef pair<LL, int> Pli;
priority_queue<Pli> que;
LL Dij(int S, int T)
{
	while (!que.empty()) que.pop();
	memset(dis, 0x3f, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dis[S] = 0;
	que.push(mp(0, S));
	while (!que.empty())
	{
		Pli c = que.top();
		que.pop();
		if (vis[c.y]) continue ;
		vis[c.y] = true;
		if (c.y == T)
			return -c.x;
		for (int i = st[c.y]; i != -1; i = g[i].next)
			if (dis[c.y] + g[i].dis < dis[g[i].id])
				dis[g[i].id] = dis[c.y] + g[i].dis,
				que.push(mp(-dis[g[i].id], g[i].id));
	}
	return dis[T];
}
void solve()
{
	for (int i = 1; i <= k; ++i)
		if (Dij(S1, p[i]) < Dij(S2, p[i]))
			g[i + m].dis = l[i];
	LL Kurumi = Dij(S2, T);
	LL Tohka = Dij(S1, T);
	if (Tohka <= Kurumi)
	{
		puts(((Tohka < Kurumi) ? ("WIN") : ("DRAW")));
		for (int i = 1; i <= k; ++i)
			printf("%d ", g[m + i].dis);
		puts("");
	}
	else
	puts("LOSE");
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
	init();
	solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <cmath>
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <bitset>
#include <memory.h>
#include <functional>
#include <queue>
#include <fstream>
#include <ctime>
#include <deque>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <cctype>
#include <numeric>
#include <iomanip>
using namespace std;
#define sqr(_) ((_)*(_))

typedef pair<int, int> Pii;
#define x first
#define y second
#define mp make_pair

typedef long long LL;

const int MAXN = 10000 + 10;

struct Graph
{
	int id, dis, next;
}g[MAXN + 200];
int n, m, k, S1, S2, T, st[MAXN], l[MAXN], r[MAXN];
bool vis[MAXN];

void Add(int tot, int x, int y, int dis)
{
	g[tot].id = y, g[tot].dis = dis, g[tot].next = st[x], st[x] = tot;
}
void init()
{
	cin >> n >> m >> k;
	cin >> S1 >> S2 >> T;
	memset(st, -1, sizeof(st));
	for (int i = 1; i <= m; ++i)
	{
		int x, y, z;
		cin >> x >> y >> z;
		Add(i, x, y, z);
	}
	for (int i = 1; i <= k; ++i)
	{
		int x, y;
		cin >> x >> y >> l[i] >> r[i];
		Add(i + m, x, y, r[i]);
	}
}
LL dis[MAXN];
typedef pair<LL, int> Pli;
priority_queue<Pli> que;
LL Dij(int S, int T)
{
	while (!que.empty()) que.pop();
	memset(dis, 0x3f, sizeof(dis));
	memset(vis, 0, sizeof(vis));
	dis[S] = 0;
	que.push(mp(0, S));
	while (!que.empty())
	{
		Pli c = que.top();
		que.pop();
		if (vis[c.y]) continue ;
		vis[c.y] = true;
		if (c.y == T)
			return -c.x;
		for (int i = st[c.y]; i != -1; i = g[i].next)
			if (dis[c.y] + g[i].dis < dis[g[i].id])
				dis[g[i].id] = dis[c.y] + g[i].dis,
				que.push(mp(-dis[g[i].id], g[i].id));
	}
	return dis[T];
}
void solve()
{
	LL Kurumi = Dij(S2, T);
	LL Tohka = Dij(S1, T);
	for (int i = 1; i <= k; ++i)
	{
		g[m + i].dis = l[i];
		LL nT = Dij(S1, T), nK = Dij(S2, T);
		if (nK - nT > Kurumi - Tohka)
			Tohka = nT, Kurumi = nK;
		else
		g[m + i].dis = r[i];
	}
	if (Tohka <= Kurumi)
	{
		puts(((Tohka < Kurumi) ? ("WIN") : ("DRAW")));
		for (int i = 1; i <= k; ++i)
			printf("%d ", g[m + i].dis);
		puts("");
	}
	else
	puts("LOSE");
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
	init();
	solve();
	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
const long long inf=(long long)(1e14);
struct ee{
    int u,v,c;
    int next;
}e[20010];
int n,m1,m2;
int s1,s2,f;
long long d[10010],d1,d2;
int head[10010],cnt,pre[10010];
int l[110],r[110],ch[110];
long long ans;
void addedge(int u,int v,int c){
    e[cnt].u=u;
    e[cnt].v=v;
    e[cnt].c=c;
    e[cnt].next=head[u];
    head[u]=cnt++;
}
int vis[10010];
queue<int> q;
int spfa(){
    int i,u,v;
    memset(vis,0,sizeof(vis));
    memset(pre,-1,sizeof(pre));
    for (i=1;i<=n;i++) d[i]=inf;
    d[f]=0;
    vis[f]=1;
    q.push(f);
    while (!q.empty()){
        u=q.front();
        q.pop();
        vis[u]=0;
        for (i=head[u];i!=-1;i=e[i].next){
            v=e[i].v;
            if (d[u]+e[i].c<d[v]){
                d[v]=d[u]+e[i].c;
                pre[v]=i;
                if (!vis[v]){
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    d1=d[s1];d2=d[s2];
    if (d1-d2<ans){
        ans=d1-d2;
        return 1;
    }
    return 0;
}
void solve(){
    int i;
    ans=inf;
    while (1){
        spfa();
        if (ans<0) break;
        for (i=pre[s2];i>=0;i=pre[e[i].u]){
            if (i>=m1&&ch[i-m1]<r[i-m1]){
                ch[i-m1]=r[i-m1];
                e[i].c=r[i-m1];
                break;
            }
        }
        if (i<0) break;
    }
    if (ans>0){
        printf("LOSE\n");
    }else{
        if (ans==0) printf("DRAW\n");
        else printf("WIN\n");
        for (i=0;i<m2-1;i++) printf("%d ",ch[i]);
        printf("%d\n",ch[i]);
    }
}
int main(){
    //freopen("e.in","r",stdin);
    int i;
    int u,v,c;
    scanf("%d%d%d",&n,&m1,&m2);
    scanf("%d%d%d",&s1,&s2,&f);
    memset(head,-1,sizeof(head));
    cnt=0;
    for (i=0;i<m1;i++){
        scanf("%d%d%d",&u,&v,&c);
        addedge(v,u,c);
    }
    for (i=0;i<m2;i++){
        scanf("%d%d%d%d",&u,&v,&l[i],&r[i]);
        ch[i]=l[i];
        addedge(v,u,l[i]);
    }
    solve();
    //while (1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

vector<int> right_mate(3*100001); // right mate
vector<int> won(3*100001); // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100001; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; cin >> l >> r >> x;
        for(int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j<=r && j!=x)
                won[j] = x;
        }
        if(l^x) right_mate[l] = x;
        if(x^r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;

vector<int> right_mate(3*100001); // right mate
vector<int> won(3*100001); // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100002; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; scanf("%d%d%d", &l, &r, &x);
        for(int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j <=r && j!=x)
                won[j] = x;
        }
        if(l != x) right_mate[l] = x;
        if(x != r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;

int right_mate[3*100001]; // right mate
int won[3*100001]; // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100002; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; cin >> l >> r >> x;
        for(register int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j <= r && j!=x)
                won[j] = x;
        }
        if(l != x) right_mate[l] = x;
        if(x != r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;

int right_mate[3*100001]; // right mate
int won[3*100001]; // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100002; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; cin >> l >> r >> x;
        for(int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j <=r && j!=x)
                won[j] = x;
        }
        if(l != x) right_mate[l] = x;
        if(x != r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;

vector<int> right_mate(3*100001); // right mate
vector<int> won(3*100001); // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100001; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; cin >> l >> r >> x;
        for(int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j<=r && j!=x)
                won[j] = x;
        }
        if(l^x) right_mate[l] = x;
        if(x^r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        printf("%d ", won[i]);
}


#include <bits/stdc++.h>
using namespace std;

vector<int> right_mate(3*100001); // right mate
vector<int> won(3*100001); // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    for(int i = 0; i <= 3*100002; ++i)
        right_mate[i] = i + 1;

    for(int i = 0; i < m; ++i){
        int l, r, x; scanf("%u%u%u", &l, &r, &x);
        for(int j = l; j <= r; j = right_mate[j])
        {
            if(!won[j] && j <=r && j!=x)
                won[j] = x;
        }
        if(l != x) right_mate[l] = x;
        if(x != r) right_mate[x] = r;
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


#include <bits/stdc++.h>
using namespace std;

int won[3*100001]; // is won by[number]
int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	std::ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    set<int> s;
    for(int i = 1; i <= n + 3; ++i) s.insert(i);
    for(int i = 0; i < m; ++i){
        int l, r, x; cin >> l >> r >> x;
        int t = *s.lower_bound(l);
        while(t <= r){
            if(t != x) won[t] = x, s.erase(t);
            t = *s.lower_bound(t + 1);
        }
    }
    for(int i = 1; i <= n; ++i)
        cout << won[i] << ' ';
}


/*

                         YATIN KWATRA                   _03_08_14

Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |

------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

void solve()
{

  int n, q, l, r, x;
  cin >> n >> q;

  set<int>s;

  fo(i, 0, n - 1) s.insert(i);

  vii won(n, -1);

  while (q--)
  {
    cin >> l >> r >> x;
    l--, r--, x--;

    auto id = lower_bound(all(s), l);

    vii era;

    while (id != s.end() and (*id) <= r)
    {
      if (*id != x) won[*id] = x;
      else
      {
        id++;
        continue;
      }
      era.pb(*id);
      id++;
    }

    for (auto &i : era) s.erase(i);

  }

  fo(i, 0, n - 1) cout << won[i] + 1 << " ";
  cout << endl;

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


/*

                         YATIN KWATRA                   _03_08_14

Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |

------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

void solve()
{

  int n, q, l, r, x;
  cin >> n >> q;

  set<int>s;

  fo(i, 0, n - 1) s.insert(i);

  vii won(n, -1);

  while (q--)
  {
    cin >> l >> r >> x;
    l--, r--, x--;

    auto id = lower_bound(all(s), l);

    while (id != s.end() and * id <= r)
    {
      if (*id != x) won[*id] = x;
      else
      {
        id++;
        continue;
      }
      auto temp = id;
      id++;
      s.erase(temp);
    }

  }

  fo(i, 0, n - 1) cout << won[i] + 1 << " ";
  cout << endl;

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


/*

                         YATIN KWATRA                   _03_08_14

Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |

------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

void solve()
{

  int n, q, l, r, x;
  cin >> n >> q;

  set<int>s;

  fo(i, 0, n - 1) s.insert(i);

  vii ans(n, -1);

  while (q--)
  {
    cin >> l >> r >> x;
    l--, r--, x--;

    auto id = s.lower_bound(l);

    while (id != s.end() and * id <= r)
    {
      if (*id ^ x)
      {
        ans[*id] = x;
        s.erase(id++);
      }
      else id++;
    }

  }

  fo(i, 0, n - 1) cout << ans[i] + 1 << " ";
  cout << endl;

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


/*

                         YATIN KWATRA                   _03_08_14

Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |

------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

void solve()
{

  int n, q, l, r, x;
  cin >> n >> q;

  set<int>s;

  fo(i, 0, n - 1) s.insert(i);

  vii won(n, -1);

  while (q--)
  {
    cin >> l >> r >> x;
    l--, r--, x--;

    auto id = lower_bound(all(s), l);

    vii era;

    while (id != s.end())
    {
      int cur = *id;

      if (cur > r) break;

      if (cur != x)
      {
        won[cur] = x;
        era.pb(cur);
      }
      id++;
    }

    for (auto &i : era) s.erase(i);

  }

  fo(i, 0, n - 1) cout << won[i] + 1 << " ";
  cout << endl;

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


/*

                         YATIN KWATRA                   _03_08_14

Let's Hoop..

------------------------------------------------

           o
 /|   o         o
 \|=--            o
    ##
                    \\
                 /   \O
                O_/   T
                T    /|
                |\  | |
 _______________|_|________

------------------------------------------------

o- - -  \o          __|
   o/   /|          vv`\
  /|     |              |
   |    / \_            |
  / \   |               |
 /  |                   |

------------------------------------------------

HOOPER_4_LYF..

*/

// AC BAKSHI RABBA

// #pragma GCC optimize "trapv"

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll                      long long
#define int                     ll
#define FIO                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pbds                    tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ld                      long double
#define ull                     unsigned long long
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int>
#define pll                     pair<ll,ll>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define MIN                     -1e9
#define pi                      3.1415926535897932384626433832795

using namespace std;
using namespace __gnu_pbds;

void INPUT()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

/*
----------------------------------------------------------------

   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Read the Question and the sample test cases carefully
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..

----------------------------------------------------------------*/

void solve()
{

  int n, q, l, r, x;
  cin >> n >> q;

  set<int>s;

  fo(i, 0, n - 1) s.insert(i);

  vii won(n, -1);
  vii era;

  while (q--)
  {
    cin >> l >> r >> x;
    l--, r--, x--;

    auto id = lower_bound(all(s), l);

    while (id != s.end() and * id <= r)
    {
      if (*id != x) won[*id] = x;
      else
      {
        id++;
        continue;
      }
      era.pb(*id);
      id++;
    }

    for (auto &i : era) s.erase(i);

  }

  fo(i, 0, n - 1) cout << won[i] + 1 << " ";
  cout << endl;

}

signed main() {

  FIO
  INPUT();

  int t;
  t = 1;
// cin >> t;

  fo(i, 0, t - 1)
  {
    solve();
  }
  return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int N = 3e5+5;
int tree[4*N], lazy[4*N], l[N], r[N], x[N];

class CKnightTournament {
public:
    int n, m;
    void push(int node, int start, int end){
        if(lazy[node]){
            tree[node] = lazy[node];
            if(start != end){
                tree[2*node] = lazy[node];
                tree[2*node + 1] = lazy[node];
            }
            lazy[node] = 0;
        }
    }
    void update(int node, int start, int end, int l, int r, int val){
        push(node, start, end);
        if(start > end or end < l or start > r) return;
        if(start >= l and end <= r){
            tree[node] = val;
            if(start != end) lazy[2*node] = lazy[2*node + 1] = val;
            return;
        }
        int mid = (start + end) >> 1;
        update(2*node, start, mid, l, r, val);
        update(2*node + 1, mid + 1, end , l, r, val);
        tree[node] = max(tree[2*node], tree[2*node + 1]);
    }
    int query(int node, int start, int end, int l, int r){
        push(node, start, end);
        if(start > end or end < l or start > r) return INT_MIN;
        if(start >= l and end <= r) return tree[node];
        int mid = (start + end) >> 1;
        return max(query(2*node, start, mid, l, r), query(2*node + 1, mid + 1, end, l, r));
    }
    void updateTree(int l, int r, int val){
        update(1, 1, n, l, r, val);
    }
    int queryTree(int l, int r){
        return query(1, 1, n, l, r);
    }
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;
		f(i, m) in >> l[i] >> r[i] >> x[i];
        for(int i = m - 1; i>=0; --i){
            updateTree(l[i], x[i] - 1, x[i]);
            updateTree(x[i] + 1, r[i], x[i]);
        }
        rep(i, 1, n) out << queryTree(i, i) << ' ';
	}
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CKnightTournament solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int N = 3e5+5;
int res[N];

class CKnightTournament {
public:
    int n, m;
    set<int> s;
    void setWin(int l, int r, int x){
        auto it = s.lower_bound(l);
        vector<int> rem;
        while(it != s.end() and *it <= r){
            res[*it] = x;
            rem.emplace_back(*it);
            ++it;
        }
        for(int y: rem) s.erase(y);
    }
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;
        rep(i, 1, n) s.insert(i);
        memset(res, 0, sizeof res);
        f(i, m){
            int l, r, x; in >> l >> r >> x;
            setWin(l, x-1, x);
            setWin(x+1, r, x);
        }
        rep(i, 1, n) out << res[i] << ' ';
	}
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CKnightTournament solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const int N = 3e5+5;
int tree[4*N], lazy[4*N], l[N], r[N], x[N];

class CKnightTournament {
public:
    int n, m;
    void push(int node, int start, int end){
        if(lazy[node]){
            tree[node] = lazy[node];
            if(start != end){
                tree[2*node] = lazy[node];
                tree[2*node + 1] = lazy[node];
            }
            lazy[node] = 0;
        }
    }
    void update(int node, int start, int end, int l, int r, int val){
        push(node, start, end);
        if(start > end or end < l or start > r) return;
        if(start >= l and end <= r){
            tree[node] = val;
            if(start != end) lazy[2*node] = lazy[2*node + 1] = val;
            return;
        }
        int mid = (start + end) >> 1;
        update(2*node, start, mid, l, r, val);
        update(2*node + 1, mid + 1, end , l, r, val);
        tree[node] = max(tree[2*node], tree[2*node + 1]);
    }
    int query(int node, int start, int end, int l, int r){
        if(start > end or end < l or start > r) return INT_MIN;
        if(start >= l and end <= r) return tree[node];
        int mid = (start + end) >> 1;
        return max(query(2*node, start, mid, l, r), query(2*node + 1, mid + 1, end, l, r));
    }
    void updateTree(int l, int r, int val){
        update(1, 1, n, l, r, val);
    }
    int queryTree(int l, int r){
        return query(1, 1, n, l, r);
    }
	void solve(std::istream& in, std::ostream& out) {
		in >> n >> m;
		f(i, m) in >> l[i] >> r[i] >> x[i];
        for(int i = m - 1; i>=0; --i){
            updateTree(l[i], x[i] - 1, x[i]);
            updateTree(x[i] + 1, r[i], x[i]);
        }
        rep(i, 1, n) out << queryTree(i, i) << ' ';
	}
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CKnightTournament solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


#include<bits/stdc++.h>
#define PI acos(-1)
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 300005
#define MXX 3005
#define mod 1000000007
#define inf 2000000000000000000
using namespace std;
ll n,m,c,a[MX];
int main()
{
    scanf("%I64d%I64d",&n,&m);
    set<ll>st;
    for(ll i=0;i<n;i++)
    {
        st.insert(i+1);
    }
    ll l,r,x;
    for(ll i=1;i<=m;i++)
    {
        scanf("%I64d%I64d%I64d",&l,&r,&x);
       set<ll>::iterator it = st.lower_bound(l);
        vector<ll>vt;
        for( ;it!=st.end();++it)
        {
            ll tmp=*it;
            if(tmp>r) break;
            if(tmp==x) continue;
            a[tmp]=x;
            vt.push_back(tmp);
        }
        for(ll j=0;j<vt.size();j++)
       st.erase(vt[j]);
    }
    a[x]=0;
    for(ll i=1;i<=n;i++)
    {
        printf("%I64d ",a[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
#define PI acos(-1)
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 300005
#define MXX 3005
#define mod 1000000007
#define inf 2000000000000000000
using namespace std;
vector<ll>vt;
ll n,m,c,a[MX];
ll pos(ll tmp)
{
  //  cout<<tmp<<endl;
    ll ans=-1,l=0,h=n,m;
   // cout<<"size "<<h+1<<endl;
    while(l<=h)
    {
        m=(l+h)/2;
        if(vt[m]==tmp) return m;
        else if(vt[m]>tmp)
        {
            ans=m;
            h=m-1;
        }
        else
            l=m+1;
    }
    return ans;
}
int main()
{
    scanf("%I64d%I64d",&n,&m);
    c=n;
    for(ll i=0;i<n;i++)
    {
        vt.push_back(i+1);
    }
    --n;
    ll l,r,x,y;
    for(ll i=1;i<=m;i++)
    {
        scanf("%I64d%I64d%I64d",&l,&r,&x);
        y=pos(l);
    //    cout<<y<<" bef y "<<endl;
        if(y==-1)
        continue;
     //   cout<<y<<" y "<<endl;
        for(ll j=y;vt[j]<=r && j<=n;j++)
        {
        //    cout<<vt[j]<<"vt"<<endl;
            if(vt[j]==x) continue;
            //cout<<vt[j]<<"vt"<<endl;
            a[vt[j]]=x;
            vt.erase(vt.begin()+j);
            --j;
            --n;
        }
    }
    a[x]=0;
    for(ll i=1;i<=c;i++)
    {
        printf("%I64d ",a[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
#define PI acos(-1)
#define ll long long int
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 300005
#define MXX 3005
#define mod 1000000007
#define inf 2000000000000000000
using namespace std;
vector<ll>vt;
ll n,m,c,a[MX];
ll pos(ll tmp)
{
  //  cout<<tmp<<endl;
    ll ans=-1,l=0,h=n,m;
   // cout<<"size "<<h+1<<endl;
    while(l<=h)
    {
        m=(l+h)/2;
        if(vt[m]==tmp) return m;
        else if(vt[m]>tmp)
        {
            ans=m;
            h=m-1;
        }
        else
            l=m+1;
    }
    return ans;
}
int main()
{
    scanf("%I64d%I64d",&n,&m);
    c=n;
    for(ll i=0;i<n;i++)
    {
        vt.push_back(i+1);
    }
    --n;
    ll l,r,x,y;
    for(ll i=1;i<=m;i++)
    {
        scanf("%I64d%I64d%I64d",&l,&r,&x);
        y=pos(l);
    //    cout<<y<<" bef y "<<endl;
        if(y==-1)
        continue;
     //   cout<<y<<" y "<<endl;
        for(ll j=y; j<=n && vt[j]<=r ;j++)
        {
        //    cout<<vt[j]<<"vt"<<endl;
            if(vt[j]==x) continue;
            //cout<<vt[j]<<"vt"<<endl;
            a[vt[j]]=x;
            vt.erase(vt.begin()+j);
            --j;
            --n;
        }
    }
    a[x]=0;
    for(ll i=1;i<=c;i++)
    {
        printf("%I64d ",a[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[300005];
int main()
{
    int n,m,l,r,x,i;
    set<int>s;
    set<int>::iterator it;
    cin>>n>>m;
    for(i=1;i<=n+1;i++)
    {
        s.insert(i);
    }
    while(m--)
    {
        cin>>l>>r>>x;
        it=s.lower_bound(l);
        while(*it<=r)
        {
            if(*it!=x)
            {
                a[*it]=x;
                s.erase(it++);
                //++it;
            }
            else
                it++;
        }

    }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[300005];
int main()
{
    int n,m,l,r,x,i;
    set<int>s;
    set<int>::iterator it;
    cin>>n>>m;
    for(i=1;i<=n+1;i++)
    {
        s.insert(i);
    }
    while(m--)
    {
        cin>>l>>r>>x;
        it=s.lower_bound(l);
        while(*it<=r)
        {
            if(*it!=x)
            {
                a[*it]=x;
                s.erase(it);
                ++it;
            }
            else
                it++;
        }

    }
    for(i=1;i<=n;i++)
    {
        cout<<a[i]<<" ";
    }

	return 0;
}


///------------------  ONESHOTAC -------------------
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
//#define f first
//#define s second
//#define int long long
using namespace std;

const int MOD=1e9+7;
const int N = 300005;
int n, T[4 * N], res[N], m;
void init(int id = 1, int l = 1, int r = n)
{
    if(l == r)
    {
        T[id] = m + 1;
        return;
    }
    int mid = (l + r)/2;
    init(id * 2, l, mid);
    init(id * 2 + 1, mid + 1, r);
    T[id] = m + 1;
}
void down(int id)
{
    if(T[id] == m + 1) return;
    int val = T[id];
    T[id] = m + 1;
    T[id * 2] = min(T[id * 2], val);
    T[id * 2 + 1] = min(T[id * 2 + 1], val);
    return;
}
void update(int id, int l, int r, int u, int v, int val)
{
    if(l > v || r < u) return;
    if(u <= l && r <= v)
    {
        T[id] = min(T[id], val);
        return;
    }
    int mid = (l + r)/2;
    down(id);
    update(id * 2, l, mid, u, v, val);
    update(id * 2 + 1, mid + 1, r, u, v, val);
    T[id] = m + 1;
}
int get(int id, int l, int r, int pos)
{
    if(l == r)
    {
        return T[id];
    }
    int mid = (l + r)/2;
    down(id);
    if(pos <= mid) return get(id * 2, l, mid, pos);
    else return get(id * 2 + 1, mid + 1, r, pos);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen("A.inp","r",stdin);
//    freopen("A.out","w",stdout);
    cin >> n >> m;
    init();
    FOR(i, 1, m)
    {
        int l, r;
        cin >> l >> r >> res[i];
        if(res[i] != l) update(1, 1, n, l, res[i] - 1, i);
        if(res[i] != r) update(1, 1, n, res[i] + 1, r, i);
    }
    FOR(i, 1, n)
    {
        int x = get(1, 1, n, i);
        if(x == m + 1) cout << 0 << " ";
        else cout << res[x] << " ";
    }
    return 0;
}


///------------------  ONESHOTAC -------------------
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
//#define f first
//#define s second
//#define int long long
using namespace std;

const int MOD=1e9+7;
const int N = 300005;
int n, T[2 * N], res[N], m;
void init(int id = 1, int l = 1, int r = n)
{
    if(l == r)
    {
        T[id] = m + 1;
        return;
    }
    int mid = (l + r)/2;
    init(id * 2, l, mid);
    init(id * 2 + 1, mid + 1, r);
    T[id] = m + 1;
}
void down(int id)
{
    if(T[id] == m + 1) return;
    int val = T[id];
    T[id] = m + 1;
    T[id * 2] = min(T[id * 2], val);
    T[id * 2 + 1] = min(T[id * 2 + 1], val);
    return;
}
void update(int id, int l, int r, int u, int v, int val)
{
    if(l > v || r < u) return;
    if(u <= l && r <= v)
    {
        T[id] = min(T[id], val);
        return;
    }
    int mid = (l + r)/2;
    down(id);
    update(id * 2, l, mid, u, v, val);
    update(id * 2 + 1, mid + 1, r, u, v, val);
    T[id] = m + 1;
}
int get(int id, int l, int r, int pos)
{
    if(l == r)
    {
        return T[id];
    }
    int mid = (l + r)/2;
    down(id);
    if(pos <= mid) return get(id * 2, l, mid, pos);
    else return get(id * 2 + 1, mid + 1, r, pos);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen("A.inp","r",stdin);
//    freopen("A.out","w",stdout);
    cin >> n >> m;
    init();
    FOR(i, 1, m)
    {
        int l, r;
        cin >> l >> r >> res[i];
        if(res[i] != l) update(1, 1, n, l, res[i] - 1, i);
        if(res[i] != r) update(1, 1, n, res[i] + 1, r, i);
    }
    FOR(i, 1, n)
    {
        int x = get(1, 1, n, i);
        if(x == m + 1) cout << 0 << " ";
        else cout << res[x] << " ";
    }
    return 0;
}


 #include <bits/stdc++.h>
using namespace std;

#define llint   long long
#define M       1000000007
#define pb      push_back
#define MP      make_pair
#define pll     pair<llint, llint>
#define F       first
#define S       second

llint dx4[4] = {0, 1, 0, -1};
llint dy4[4] = {1, 0, -1, 0};
llint dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
llint dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

//freopen("input.txt",  "r",  stdin);     freopen("output.txt", "w", stdout);

llint n, m;
cin >> n >> m;

bool alive[n+1];
llint next[n+1];
llint ans[n+1];

for (llint i = 1; i <= n; i++)
{
    alive[i] = true;
    next[i] = i+1;
    ans[i] = 0;
}

while (m--)
{
    llint l, r, x;
    cin >> l >> r >> x;

    llint i = l;
    while (i <= r)
    {
        llint ni = next[i];
        if (i != x && alive[i])
        {
            alive[i] = false;
            ans[i] = x;
        }
        if (i < x)  next[i] = x;
        else        next[i] = r+1;
        i = ni;
    }

    next[l-1] = x;
    next[x] = r+1;
}

for (llint i = 1; i <= n; i++)  cout << ans[i] << " ";

}


 #include <bits/stdc++.h>
using namespace std;

#define llint   long long
#define M       1000000007
#define pb      push_back
#define MP      make_pair
#define pll     pair<llint, llint>
#define F       first
#define S       second

llint dx4[4] = {0, 1, 0, -1};
llint dy4[4] = {1, 0, -1, 0};
llint dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
llint dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

//freopen("input.txt",  "r",  stdin);     freopen("output.txt", "w", stdout);

llint n, m;
cin >> n >> m;

bool alive[n+1];
llint next[n+1];
llint ans[n+1];

for (llint i = 1; i <= n; i++)
{
    alive[i] = true;
    next[i] = i+1;
    ans[i] = 0;
}

while (m--)
{
    llint l, r, x;
    cin >> l >> r >> x;

    llint i = l;
    while (i <= r)
    {
        llint ni = next[i];
        if (i != x && alive[i])
        {
            alive[i] = false;
            ans[i] = x;
            if (i < x)  next[i] = x;
            else        next[i] = r+1;
        }
        i = ni;
    }

    next[l-1] = x;
    next[x] = r+1;
}

for (llint i = 1; i <= n; i++)  cout << ans[i] << " ";

}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 300005;
int defeatedBy[MAX_N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    set<int> s;
    for (int i = 1; i <= n + 1; ++i) // to n + 1 intended to avoid s.end()
        s.insert(i);
    while(m--)
    {
        int l, r, w;
        cin >> l >> r >> w;
        int cur = l;
        while(cur <= r)
        {
            auto it = s.lower_bound(cur);
            int nextValue = *it;
            if (nextValue > r)
                break;
            if (nextValue != w)
            {
                defeatedBy[nextValue] = w;
                s.erase(it);
            }
            cur = nextValue + 1;
        }
    }

    for (int i = 1; i <= n; ++i)
        cout << defeatedBy[i] << ' ';
    return 0;
}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 300005;
int defeatedBy[MAX_N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    set<int> s;
    for (int i = 1; i <= n; ++i)
        s.insert(i);
    while(m--)
    {
        int l, r, w;
        cin >> l >> r >> w;
        int cur = l;
        while(cur <= r)
        {
            auto it = s.lower_bound(cur);
            if (it == s.end())
                break;
            int nextValue = *it;
            if (nextValue != w)
            {
                defeatedBy[nextValue] = w;
                s.erase(it);
            }
            cur = nextValue + 1;
        }
    }

    for (int i = 1; i <= n; ++i)
        cout << defeatedBy[i] << ' ';
    return 0;
}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 300005;
int defeatedBy[MAX_N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    set<int> s;
    for (int i = 1; i <= n + 1; ++i) // to n + 1 intended to avoid s.end()
        s.insert(i);
    while(m--)
    {
        int l, r, w;
        cin >> l >> r >> w;
        int cur = l;
        while(cur <= r)
        {
            auto it = s.lower_bound(cur);
            int x = *it;
            while(x <= r)
            {
                if (x != w)
                {
                    defeatedBy[x] = w;
                    it = s.erase(it);
                }
                else
                    it++;
                x = *it; // will never reach s.end() cuz i inserted n + 1
            }
            cur = x;
        }
    }

    for (int i = 1; i <= n; ++i)
        cout << defeatedBy[i] << ' ';
    return 0;
}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 300005;
int nextValid[MAX_N], defeatedBy[MAX_N];

int findNextValue(int i)
{
    if (nextValid[i] == i)
        return i;
    return nextValid[i] = findNextValue(nextValid[i]);
}

// update a deleted range
void update(int l, int r)
{
    if (l > r)
        return;
    for (int i = l; i <= r; ++i)
    {
        i = findNextValue(i);
        if (i > r)
            break;
        nextValid[i] = findNextValue(r + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n + 1; ++i)
        nextValid[i] = i;
    while(m--)
    {
        int l, r, w;
        cin >> l >> r >> w;
        for (int i = l; i <= r; ++i)
        {
            i = findNextValue(i);
            if (i > r)
                break;
            if (!defeatedBy[i] && i != w)
                defeatedBy[i] = w;
        }
        update(l, w - 1);
        update (w + 1, r);
    }

    for (int i = 1; i <= n; ++i)
        cout << defeatedBy[i] << ' ';
    return 0;
}


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 300005;
int defeatedBy[MAX_N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    set<int> s;
    for (int i = 1; i <= n + 1; ++i)
        s.insert(i);
    while(m--)
    {
        int l, r, w;
        cin >> l >> r >> w;
        int cur = l;
        while(cur <= r)
        {
            auto it = s.lower_bound(cur);
            int nextValue = *it;
            if (nextValue != w)
            {
                defeatedBy[nextValue] = w;
                s.erase(it);
            }
            cur = nextValue + 1;
        }
    }

    for (int i = 1; i <= n; ++i)
        cout << defeatedBy[i] << ' ';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fori(a,b,c) for (ll(a) = (b);(a)<(c);++(a))
#define foreq(a,b,c) for (ll(a) = (b);(a)<=(c);++(a))
#define forrev(a,b,c) for (ll(a) = (b);(a)>=(c);--(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
typedef string str;
typedef pair<ll, ll> pii;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<ll> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<pii> vii;
double PI = acos(-1);
void yes()
{
    cout << "YES\n";
}

void no()
{
    cout << "NO\n";
}

void yesno(ll f)
{
    if (f)
        yes();
    else
        no();
}

int main(){FIN;
    int n,m;cin>>n>>m;
    vi ans(n+1,-1);
    set<int> rem;
    fori(i,1,n+1)rem.insert(i);
    while(m--){
        int l,r;cin>>l>>r;
        vi toerase;
        int x;cin>>x;
        auto it = rem.lower_bound(l);
        while(it!=rem.end()){
            if(*it>r)break;
            if(*it!=x)ans[*it]=x,toerase.pb(*it);
            it++;
        }
        for(auto x:toerase) rem.erase(x);
    }
    foreq(i,1,n)
        if(ans[i]==-1)cout<<"0 ";
        else cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fori(a,b,c) for (ll(a) = (b);(a)<(c);++(a))
#define foreq(a,b,c) for (ll(a) = (b);(a)<=(c);++(a))
#define forrev(a,b,c) for (ll(a) = (b);(a)>=(c);--(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
typedef string str;
typedef pair<ll, ll> pii;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<ll> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<pii> vii;
double PI = acos(-1);
void yes()
{
    cout << "YES\n";
}

void no()
{
    cout << "NO\n";
}

void yesno(ll f)
{
    if (f)
        yes();
    else
        no();
}

int main(){FIN;
    int n,m;cin>>n>>m;
    vi ans(n+1,-1);
    set<int> rem;
    fori(i,1,n+1)rem.insert(i);
    while(m--){
        int l,r;cin>>l>>r;
        int x;cin>>x;
        auto it = rem.lower_bound(l);
        while(1){
            if(*it>r)break;
            if(*it!=x)ans[*it]=x,rem.erase(*it);
            it++;
        }
    }
    foreq(i,1,n)
        if(ans[i]==-1)cout<<"0 ";
        else cout<<ans[i]<<" ";
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int c[1000000];
int b[1000000];
int a[1000000][3];
int get(int p,int n)
{if(p>n)
return p;
    if(c[p]==p)
    return p;
    return c[p]=get(c[p],n);
}
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,l,r,x;
    for(i=0;i<m;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(i=1;i<=n;i++)
    c[i]=i;
    int p;
    for(i=0;i<m;i++)
{
    l=a[i][0];
    r=a[i][1];
    x=a[i][2];
    p=get(l,n);
    while(p<=r)
    {
if(p==x)
p++;
else
{
b[p]=x;
c[p]=p+1;
}
if(p==r)
break;
p=get(p,n);

    }
}
    for(i=1;i<=n;i++)
    cout<<b[i]<<" ";

    return 0;
}