human
Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer.

Once a year the President visited his historic home town t, for which his motorcade passes along some path from s to t (he always returns on a personal plane). Since the president is a very busy man, he always chooses the path from s to t, along which he will travel the fastest.

The ministry of Roads and Railways wants to learn for each of the road: whether the President will definitely pass through it during his travels, and if not, whether it is possible to repair it so that it would definitely be included in the shortest path from the capital to the historic home town of the President. Obviously, the road can not be repaired so that the travel time on it was less than one. The ministry of Berland, like any other, is interested in maintaining the budget, so it wants to know the minimum cost of repairing the road. Also, it is very fond of accuracy, so it repairs the roads so that the travel time on them is always a positive integer.

Input

The first lines contain four integers n, m, s and t (2 ≤ n ≤ 105.
1 ≤ m ≤ 105.
1 ≤ s, t ≤ n) — the number of cities and roads in Berland, the numbers of the capital and of the Presidents' home town (s ≠ t).

Next m lines contain the roads. Each road is given as a group of three integers ai, bi, li (1 ≤ ai, bi ≤ n.
ai ≠ bi.
1 ≤ li ≤ 106) — the cities that are connected by the i-th road and the time needed to ride along it. The road is directed from city ai to city bi.

The cities are numbered from 1 to n. Each pair of cities can have multiple roads between them. It is guaranteed that there is a path from s to t along the roads.

Output

Print m lines. The i-th line should contain information about the i-th road (the roads are numbered in the order of appearance in the input).

If the president will definitely ride along it during his travels, the...
Solve the task in PYTHON3.
assistant
#Here is Python program to print m lines.

#!/usr/bin/env python3
import heapq
INF = int(1e18)
MOD = (1 << 32) - 1

class MinHeap:
    def __init__(self): self.h = []
    def push(self, x): heapq.heappush(self.h, x)
    def pop(self): return heapq.heappop(self.h)
    def isEmpty(self): return len(self.h) == 0

def add(x, y): return x + y - MOD if x + y >= MOD else x + y
def mul(x, y): return x * y % MOD

def go(adj, src):
    n = len(adj)
    frontier = MinHeap()
    ways = [0] * n
    cost = [INF] * n

    frontier.push((0, src))
    ways[src] = 1
    cost[src] = 0
    while not frontier.isEmpty():
        c, u = frontier.pop()
        if c > cost[u]:
            continue
        for v, w in adj[u]:
            if c + w < cost[v]:
                ways[v] = ways[u]
                cost[v] = c + w
                frontier.push((c + w, v))
            elif c + w == cost[v]:
                ways[v] = add(ways[v], ways[u])

    return cost, ways

n, m, s, t = map(int, input().split())
s -= 1
t -= 1
adj = [[] for i in range(n)]
adj_transpose = [[] for i in range(n)]
edges = []
for i in range(m):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges.append((u, v, w))
    adj[u].append((v, w))
    adj_transpose[v].append((u, w))

cost_s, ways_s = go(adj, s)
cost_t, ways_t = go(adj_transpose, t)

shortest_path = cost_s[t]

for i in range(m):
    u, v, w = edges[i]
    cost = cost_s[u] + cost_t[v] + w
    if cost > shortest_path:
        fix_cost = cost - shortest_path + 1
        w -= cost - shortest_path + 1
        print(f"CAN {fix_cost}" if w >= 1 else "NO")
    else:
        if ways_s[t] == mul(ways_s[u], ways_t[v]):
            print("YES")
        else:
            print("CAN 1" if w > 1 else "NO")