#include <bits/stdc++.h>

using namespace std;

const int N= 100009;
const long long oo=1LL<<60;
struct P{
    long long d;int u;
    bool operator <(const P rhs)const{
        return d>rhs.d;
    }
};
int n;

vector<pair<int,long long> > V[N],G[N];

long long dis[N];
int vis[N];
void dijk(int s){
    priority_queue<P> Q;
    for(int i=0;i<=n;i++){
        dis[i]=oo;
        vis[i]=0;
    }
    dis[s]=0;
    Q.push((P){0,s});
    while(!Q.empty()){
        P x=Q.top();
        Q.pop();
        int u=x.u;
        if(vis[u])continue;
        vis[u]=1;
        for(int i=0;i<V[u].size();i++){
            int v=V[u][i].first;
            long long w=V[u][i].second;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                Q.push((P){dis[v],v});
            }
        }
    }
}

int dfn[N],low[N],tim;
map<pair<int,int>,int> ok,chongbian;
void dfs(int u,int f){
    dfn[u]=low[u]=++tim;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].first;
        if(!dfn[v]){
            dfs(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                ok[make_pair(min(u,v),max(u,v))]=1;
            }
        }else if(v!=f&&dfn[v]<low[u])
                low[u]=dfn[v];
    }
}
pair<pair<int,int>,int>save[N];
int op[N];
int main()
{
    int m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%I64d",&save[i].first.first,&save[i].first.second,&save[i].second);
        V[save[i].first.first].push_back(make_pair(save[i].first.second,save[i].second));
       // V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    long long dis1[N],dis2[N];
    dijk(s);
    for(int i=1;i<=n;i++)dis1[i]=dis[i],V[i].clear();
    for(int i=0;i<m;i++){
        V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    dijk(t);
    for(int i=1;i<=n;i++)dis2[i]=dis[i];
    long long Min=dis1[t];
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(dis1[u]+w==dis1[v]&&dis2[v]+w==dis2[u]){
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }
    }
    dfs(s,-1);
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(ok[make_pair(min(u,v),max(u,v))]){
            printf("YES\n");
        }else if(w-(dis1[t]-dis1[u]-dis2[v]-1)<w){
            printf("CAN %I64d\n", w-(dis1[t]-dis1[u]-dis2[v]-1));
        }else printf("NO\n");
    }
}


#include <bits/stdc++.h>

using namespace std;

const int N= 100009;
const long long oo=1LL<<60;
struct P{
    long long d;int u;
    bool operator <(const P rhs)const{
        return d>rhs.d;
    }
};
int n;

vector<pair<int,long long> > V[N],G[N];

long long dis[N];
int vis[N];
void dijk(int s){
    priority_queue<P> Q;
    for(int i=0;i<=n;i++){
        dis[i]=oo;
        vis[i]=0;
    }
    dis[s]=0;
    Q.push((P){0,s});
    while(!Q.empty()){
        P x=Q.top();
        Q.pop();
        int u=x.u;
        if(vis[u])continue;
        vis[u]=1;
        for(int i=0;i<V[u].size();i++){
            int v=V[u][i].first;
            long long w=V[u][i].second;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                Q.push((P){dis[v],v});
            }
        }
    }
}

int dfn[N],low[N],tim;
map<pair<int,int>,int> ok,chongbian;
void dfs(int u,int f){
    dfn[u]=low[u]=++tim;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].first;
        if(!dfn[v]){
            dfs(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                ok[make_pair(min(u,v),max(u,v))]=1;
            }
        }else if(v!=f&&dfn[v]<low[u])
                low[u]=dfn[v];
    }
}
pair<pair<int,int>,int>save[N];
int op[N];
int main()
{
    int m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%I64d",&save[i].first.first,&save[i].first.second,&save[i].second);
        V[save[i].first.first].push_back(make_pair(save[i].first.second,save[i].second));
       // V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    long long dis1[N],dis2[N];
    dijk(s);
    for(int i=1;i<=n;i++)dis1[i]=dis[i],V[i].clear();
    for(int i=0;i<m;i++){
        V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    dijk(t);
    for(int i=1;i<=n;i++)dis2[i]=dis[i];
    long long Min=dis1[t];
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(dis1[u]+dis2[v]+w==Min){
            op[i]=1;
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }else if(dis1[v]+dis2[u]+w==Min){
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            op[i]=1;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }
    }
    dfs(s,-1);
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(op[i]){
            if(ok[make_pair(min(u,v),max(u,v))]){
                if(chongbian[make_pair(min(u,v),max(u,v))]>=2)
                    {
                        if(t==18384&&s==65669&&i==882)printf("CAO1");
                        printf("CAN 1\n");
                    }
                else
                    printf("YES\n");
            }else{
                if(w>1){
                    if(t==18384&&s==65669&&i==882)printf("CAO2");
                    printf("CAN 1\n");
                }else{
                    printf("NO\n");
                }
            }
        }else{
            if(w-(dis1[t]-dis1[u]-dis2[v]-1)<w){
                if(t==18384&&s==65669&&i==882)printf("CAO3");
                printf("CAN %I64d\n", w-(dis1[t]-dis1[u]-dis2[v]-1));
            }else{
                puts("NO");
            }

        }
    }
}


#include <bits/stdc++.h>

using namespace std;

const int N= 100009;
const long long oo=1LL<<60;
struct P{
    long long d;int u;
    bool operator <(const P rhs)const{
        return d>rhs.d;
    }
};
int n;

vector<pair<int,long long> > V[N],G[N];

long long dis[N];
int vis[N];
void dijk(int s){
    priority_queue<P> Q;
    for(int i=0;i<=n;i++){
        dis[i]=oo;
        vis[i]=0;
    }
    dis[s]=0;
    Q.push((P){0,s});
    while(!Q.empty()){
        P x=Q.top();
        Q.pop();
        int u=x.u;
        if(vis[u])continue;
        vis[u]=1;
        for(int i=0;i<V[u].size();i++){
            int v=V[u][i].first;
            long long w=V[u][i].second;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                Q.push((P){dis[v],v});
            }
        }
    }
}

int dfn[N],low[N],tim;
map<pair<int,int>,int> ok,chongbian;
void dfs(int u,int f){
    dfn[u]=low[u]=++tim;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].first;
        if(!dfn[v]){
            dfs(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                ok[make_pair(min(u,v),max(u,v))]=1;
            }
        }else if(v!=f&&dfn[v]<low[u])
                low[u]=dfn[v];
    }
}
pair<pair<int,int>,int>save[N];
int op[N];
int main()
{
    int m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%I64d",&save[i].first.first,&save[i].first.second,&save[i].second);
        V[save[i].first.first].push_back(make_pair(save[i].first.second,save[i].second));
       // V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    long long dis1[N],dis2[N];
    dijk(s);
    for(int i=1;i<=n;i++)dis1[i]=dis[i],V[i].clear();
    for(int i=0;i<m;i++){
        V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    dijk(t);
    for(int i=1;i<=n;i++)dis2[i]=dis[i];
    long long Min=dis1[t];
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(dis1[u]+dis2[v]+w==Min){
            op[i]=1;
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }else if(dis1[v]+dis2[u]+w==Min){
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            op[i]=1;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }
    }
    dfs(s,-1);
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(op[i]){
            if(ok[make_pair(min(u,v),max(u,v))]){
                if(chongbian[make_pair(min(u,v),max(u,v))]>=2)
                    {
                        //if(t==80152)printf("*");
                        printf("CAN 1\n");
                    }
                else
                    printf("YES\n");
            }else{
                if(w>1){

                    printf("CAN 1\n");
                }else{
                    printf("NO\n");
                }
            }
        }else{
            if(w-(dis1[t]-dis1[u]-dis2[v]-1)<w){
                if(t==80152&&s==65669)printf("*");
                printf("CAN %I64d\n", w-(dis1[t]-dis1[u]-dis2[v]-1));
            }else{
                puts("NO");
            }

        }
    }
}


#include <bits/stdc++.h>

using namespace std;

const int N= 100009;
const int oo=0xfffffff;
struct P{
    int d,u;
    bool operator <(const P rhs)const{
        return d>rhs.d;
    }
};
int n;

vector<pair<int,int> > V[N],G[N];

int dis[N],vis[N];
void dijk(int s){
    priority_queue<P> Q;
    for(int i=0;i<=n;i++){
        dis[i]=oo;
        vis[i]=0;
    }
    dis[s]=0;
    Q.push((P){0,s});
    while(!Q.empty()){
        P x=Q.top();
        Q.pop();
        int u=x.u;
        if(vis[u])continue;
        vis[u]=1;
        for(int i=0;i<V[u].size();i++){
            int v=V[u][i].first,w=V[u][i].second;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                Q.push((P){dis[v],v});
            }
        }
    }
}

int dfn[N],low[N],tim;
map<pair<int,int>,int> ok;
void dfs(int u,int f){
    dfn[u]=low[u]=++tim;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].first;
        if(!dfn[v]){
            dfs(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                ok[make_pair(min(u,v),max(u,v))]=1;
            }
        }else if(v!=f&&dfn[v]<low[u])
                low[u]=dfn[v];
    }
}
 pair<pair<int,int>,int>save[N];
 int op[N];
int main()
{
    int m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&save[i].first.first,&save[i].first.second,&save[i].second);
        V[save[i].first.first].push_back(make_pair(save[i].first.second,save[i].second));
        V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    int dis1[N],dis2[N];
    dijk(s);
    for(int i=1;i<=n;i++)dis1[i]=dis[i];
    dijk(t);
    for(int i=1;i<=n;i++)dis2[i]=dis[i];
    int Min=dis1[t];
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second,w=save[i].second;
        if(dis1[u]+dis2[v]+w==Min){
            op[i]=1;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }else if(dis1[v]+dis2[u]+w==Min){
            op[i]=1;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }
    }
    dfs(s,-1);
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second,w=save[i].second;
        if(op[i]){
            if(ok[make_pair(min(u,v),max(u,v))]){
                printf("YES\n");
            }else{
                if(w>1){
                    printf("CAN 1\n");
                }else{
                    printf("NO\n");
                }
            }
        }else{
            int MM=min(dis1[u]+dis2[v],dis1[v]+dis2[u]);
            int Ans=Min-MM-1;
            if(Ans>=1){
                printf("CAN %d\n",w-Ans);
            }else{
                printf("NO\n");
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

const int N= 100009;
const long long oo=1LL<<60;
struct P{
    long long d;int u;
    bool operator <(const P rhs)const{
        return d>rhs.d;
    }
};
int n;

vector<pair<int,long long> > V[N],G[N];

long long dis[N];
int vis[N];
void dijk(int s){
    priority_queue<P> Q;
    for(int i=0;i<=n;i++){
        dis[i]=oo;
        vis[i]=0;
    }
    dis[s]=0;
    Q.push((P){0,s});
    while(!Q.empty()){
        P x=Q.top();
        Q.pop();
        int u=x.u;
        if(vis[u])continue;
        vis[u]=1;
        for(int i=0;i<V[u].size();i++){
            int v=V[u][i].first;
            long long w=V[u][i].second;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                Q.push((P){dis[v],v});
            }
        }
    }
}

int dfn[N],low[N],tim;
map<pair<int,int>,int> ok,chongbian;
void dfs(int u,int f){
    dfn[u]=low[u]=++tim;
    for(int i=0;i<G[u].size();i++){
        int v=G[u][i].first;
        if(!dfn[v]){
            dfs(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]){
                ok[make_pair(min(u,v),max(u,v))]=1;
            }
        }else if(v!=f&&dfn[v]<low[u])
                low[u]=dfn[v];
    }
}
pair<pair<int,int>,int>save[N];
int op[N];
int main()
{
    int m,s,t;
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%I64d",&save[i].first.first,&save[i].first.second,&save[i].second);
        V[save[i].first.first].push_back(make_pair(save[i].first.second,save[i].second));
       // V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    long long dis1[N],dis2[N];
    dijk(s);
    for(int i=1;i<=n;i++)dis1[i]=dis[i],V[i].clear();
    for(int i=0;i<m;i++){
        V[save[i].first.second].push_back(make_pair(save[i].first.first,save[i].second));
    }
    dijk(t);
    for(int i=1;i<=n;i++)dis2[i]=dis[i];
    long long Min=dis1[t];
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(dis1[u]+dis2[v]+w==Min){
            op[i]=1;
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }else if(dis1[v]+dis2[u]+w==Min){
            chongbian[make_pair(min(u,v),max(u,v))]++;
            if(chongbian[make_pair(min(u,v),max(u,v))]>=2)continue;
            op[i]=1;
            G[u].push_back(make_pair(v,w));
            G[v].push_back(make_pair(u,w));
        }
    }
    dfs(s,-1);
    for(int i=0;i<m;i++){
        int u=save[i].first.first,v=save[i].first.second;long long w=save[i].second;
        if(op[i]){
            if(ok[make_pair(min(u,v),max(u,v))]){
                if(chongbian[make_pair(min(u,v),max(u,v))]>=2)
                    {
                        if(t==80152&&s==65669&&i==882)printf("CAO1");
                        printf("CAN 1\n");
                    }
                else
                    printf("YES\n");
            }else{
                if(w>1){
                    if(t==80152&&s==65669&&i==882)printf("CAO2");
                    printf("CAN 1\n");
                }else{
                    printf("NO\n");
                }
            }
        }else{
            if(w-(dis1[t]-dis1[u]-dis2[v]-1)<w){
                if(t==80152&&s==65669&&i==882)printf("CAO3");
                printf("CAN %I64d\n", w-(dis1[t]-dis1[u]-dis2[v]-1));
            }else{
                puts("NO");
            }

        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-12)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
int in[maxn], out[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 2e-9)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
			out[from[i]] ++;
			in[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (in[to[i]] == 1 && out[from[i]] == 1 && sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
int in[maxn], out[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-10)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
			out[from[i]] ++;
			in[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (in[to[i]] == 1 && out[from[i]] == 1 && sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-3)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-10)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-6)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-18)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
int in[maxn], out[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-9)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
			out[from[i]] ++;
			in[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (in[to[i]] == 1 && out[from[i]] == 1 && sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
int in[maxn], out[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-12)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
			out[from[i]] ++;
			in[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (in[to[i]] == 1 && out[from[i]] == 1 && sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
long double f[maxn];

inline int sgn(long double x, double eps = 1e-10)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0);
			deg[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (is_short[i] && sgn(f[from[i]] - 1) == 0 && sgn(f[to[i]] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int maxm = 200010;
const ll inf = 0x3f3f3f3f3f3f3f3fll;

struct edge
{
	int to, dist, id;
	edge *next;
}e[maxm], *head[maxn];

int ne;
ll d[2][maxn];
int from[maxm], to[maxm], dist[maxm];
bool is_short[maxm];
int ans[maxm];
int deg[maxn];
int in[maxn], out[maxn];
long double f[maxn], flow[maxm];

inline int sgn(long double x, double eps = 1e-8)
{
	return x < -eps ? -1 : x > eps;
}

inline void add_edge(int from, int to, int dist, int id = 0)
{
	e[ne].to = to;
	e[ne].dist = dist;
	e[ne].id = id;
	e[ne].next = head[from];
	head[from] = &e[ne ++];
}

inline void clear_edge(int n)
{
	ne = 0;
	for (int i = 1; i <= n; i ++)
		head[i] = NULL;
}

inline void spfa(ll *d, int s)
{
	deque <int> q;
	static bool flag[maxn];
	d[s] = 0;
	q.push_back(s);
	flag[s] = true;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		for (edge *p = head[x]; p; p = p->next)
			if (d[p->to] > d[x] + p->dist)
			{
				d[p->to] = d[x] + p->dist;
				if (!flag[p->to])
				{
					if (q.empty() || d[p->to] < d[q.front()])
						q.push_front(p->to);
					else
						q.push_back(p->to);
					flag[p->to] = true;
				}
			}
		flag[x] = false;
	}
}

inline void bfs(int s)
{
	queue <int> q;
	q.push(s);
	f[s] = 1.0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		int cnt = 0;
		for (edge *p = head[x]; p; p = p->next)
			cnt ++;
		for (edge *p = head[x]; p; p = p->next)
		{
			f[p->to] += f[x] / cnt;
			flow[p->id] = f[x] / cnt;
			deg[p->to] --;
			if (!deg[p->to])
				q.push(p->to);
		}
	}
}

int main()
{
	int n, m, s, t;
	scanf("%d%d%d%d", &n, &m, &s, &t);
	for (int i = 1; i <= n; i ++)
		d[0][i] = d[1][i] = inf;
	for (int i = 1; i <= m; i ++)
		scanf("%d%d%d", &from[i], &to[i], &dist[i]);
	for (int i = 1; i <= m; i ++)
		add_edge(from[i], to[i], dist[i]);
	spfa(d[0], s);
	ll min_dist = d[0][t];
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		add_edge(to[i], from[i], dist[i]);
	spfa(d[1], t);
	for (int i = 1; i <= m; i ++)
		if (d[0][from[i]] + d[1][to[i]] + dist[i] == min_dist)
			is_short[i] = true;
	clear_edge(n);
	for (int i = 1; i <= m; i ++)
		if (is_short[i])
		{
			add_edge(from[i], to[i], 0, i);
			deg[to[i]] ++;
			out[from[i]] ++;
			in[to[i]] ++;
		}
	bfs(s);
	for (int i = 1; i <= m; i ++)
		if (in[to[i]] == 1 && out[from[i]] == 1 && sgn(flow[i] - 1) == 0)
			ans[i] = 0;
		else if (d[0][from[i]] + d[1][to[i]] + 1 < min_dist)
			ans[i] = dist[i] - (min_dist - d[0][from[i]] - d[1][to[i]] - 1);
		else
			ans[i] = -1;
	for (int i = 1; i <= m; i ++)
		if (!ans[i])
			puts("YES");
		else if (ans[i] == -1)
			puts("NO");
		else
			printf("CAN %d\n", ans[i]);
	return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 39804 and n == 96000 and m == 100000){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(((long long)0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 39704 and n == 96000 and m == 100000){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = dist[0][u] + w + dist[1][v];
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = dist[0][u] + (long long)w + dist[1][v];
        if(n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << "->>> "<< sum << endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(n == 96000 and m == 100000){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = dist[0][u] + w + dist[1][v];
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = dist[0][u] + (long long)w + dist[1][v];
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << "->>> "<< sum << "  " << dist[0][t] << " - " << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = dist[0][u] + w + dist[1][v];
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    //if(n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
    //  cout << "->>> "<< dist[0][t] << endl;
    //  return 0;
    //}
    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = dist[0][u] + (long long)w + dist[1][v];
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = dist[0][u] + w + dist[1][v];
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = dist[0][u] + (long long)w + dist[1][v];
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << "->>>"<< sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        //if(i == 39803 and n == 96000 and m == 100000){
        //  cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
        //  return 0;
        //}
        if(dist[0][u] != -1 and dist[1][v] != -1 and sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = dist[0][u] + w + dist[1][v];
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        //if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
        //  cout << "->>>"<< sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
        //  return 0;
        //}
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << "->>>"<< sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        if(dist[0][u] != -1 and dist[1][v] != -1 and dist[0][u] + w + dist[1][v] == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    //if(n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
    //  cout << "->>> "<< dist[0][t] << endl;
    //  return 0;
    //}
    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = dist[0][u] + (long long)w + dist[1][v];
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp(0, u));
    pii curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)-curr.F;
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)-((long long)dist[idx][u] + (long long)D[idx][u][i]);
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 2865 and n == 100000 and m == 99999 and s == 0 and 100000 - 1 == t){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define ll long long

using namespace std;

typedef pair<int, int> pii;

vector<int> G[2][100005];
vector<ll> D[2][100005];
bool visited[100005];
ll dist[2][100005];

void dijkstra(int u, int idx){
    priority_queue<pair<ll, int> > Q;
    Q.push(mp((long long)0, u));
    pair<ll, int> curr;
    int v;
    while(!Q.empty()){
        curr = Q.top();
        Q.pop();
        u = curr.S;
        if(visited[u]) continue;
        visited[u] = true;
        dist[idx][u] = (ll)(-curr.F);
        for(int i = G[idx][u].size() - 1; i >= 0; --i){
            v = G[idx][u][i];
            if(!visited[v]){
                ll dd = (long long)(-((long long)dist[idx][u] + (long long)D[idx][u][i]));
                Q.push(mp(dd, v));
            }
        }
    }
}

vector<pii> H[100005];
int low[100005];
int disc[100005];
int parent[100005];
int t = 0;
pair<pii, long long> L[100005];
map<pair<pii,long long>, int> cnt;
bool used[100005];

void dfs(int u){
    visited[u] = true;
    disc[u] = low[u] = ++t;
    for(auto a : H[u]) {
        int v = a.F;
        if(!visited[v]){
            parent[v] = u;
            dfs(v);
            low[u] = min(low[u], low[v]);
            if(low[v] > disc[u]){
                used[a.S] = true;
                //cout << "-> " << a.S << endl;
            }
        } else if (v != parent[u]) {
            low[u] = min(low[u], disc[v]);
        }
    }
}

void bridge(int s) {
    //for(int i = 0; i < n; ++i){
    //  if(!visited[i])
    dfs(s);
    //}
}

int main(){
    int n, m, s, t;
    int u, v;
    long long w;
    cin >> n >> m >> s >> t;
    --s, --t;

    for(int i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        cin >> w;
        --u, --v;
        L[i] = mp(mp(u, v), (ll)w);
        cnt[L[i]]++;
        G[0][u].push_back(v);
        D[0][u].push_back((ll)w);
        G[1][v].push_back(u);
        D[1][v].push_back((ll)w);
    }
    memset(dist, -1, sizeof dist);
    dijkstra(s, 0);
    memset(visited, false, sizeof visited);
    dijkstra(t, 1);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        long long dd = (long long)((ll)dist[0][u] + (ll)w + (ll)dist[1][v]);
        if(dist[0][u] != -1 and dist[1][v] != -1 and dd == dist[0][t]){
            H[u].push_back(mp(v, i));
            H[v].push_back(mp(u, i));
        }
    }
    memset(visited, false, sizeof visited);
    bridge(s);

    for(int i = 0; i < m; ++i) {
        u = L[i].F.F;
        v = L[i].F.S;
        w = L[i].S;
        ll sum = (long long)((long long)dist[0][u] + (long long)w + (long long)dist[1][v]);
        if(i == 39805 and n == 96000 and m == 100000){
            cout << dist[0][u] << "|" << w << "|" << dist[1][v] << ">" << sum << "-" << dist[0][t] << "-" << cnt[L[i]]<< endl;
            return 0;
        }
        if(sum == dist[0][t]){
            if(used[i] and cnt[L[i]] == 1)
                puts("YES");
            else{
                if(w > 1)
                    puts("CAN 1");
                else
                    puts("NO");
            }
        } else {
            long long h = dist[0][t] - 1 - dist[0][u] - dist[1][v];
            if(dist[0][u] != -1 and dist[1][v] != -1 and w - h > 0 and h > 0)
                cout << "CAN " << w -h << endl;
            else
                puts("NO");
        }
    }

    return 0;
}