Easy Compare-and-Set

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Let us define "Compare-and-Set" operation for a global variable vv. The operation checks if the variable is equal to aa. If that's true, the variable value changes to bb and the operation succeeds. Otherwise, the variable doesn't change and the operation fails. Let us denote the operation as CAS(a,b)\operatorname{CAS}(a,b).

Imagine that you are given a list of such operations CAS(a_1,b_1),,CAS(a_n,b_n)\operatorname{CAS}(a\_1,b\_1), \dots, \operatorname{CAS}(a\_n,b\_n). Also, you are given an initial value for the variable, cc, and a list of wishes w_1,w_nw\_1, \dots w\_n, where w_iw\_i tells whether the operation CAS(a_i,b_i)\operatorname{CAS}(a\_i,b\_i) should be successful. Your task is to determine the order of operations execution so that all the wishes are satisfied.

입력

The first line contains two integers nn and cc (1n1051 \le n \le 10^5; 1c1091 \le c \le 10^9) --- the number of operations and the initial value of the variable.

Each of the next nn lines contains three integers a_i,b_i,w_ia\_i, b\_i, w\_i (1a_i,b_i1091 \le a\_i, b\_i \le 10^9; 0w_i10 \le w\_i \le 1), denoting CAS(a_i,b_i)\operatorname{CAS}(a\_i, b\_i) operation that you wish to be successful if w_i=1w\_i = 1 and unsuccessful if w_i=0w\_i = 0. The operations are numbered from 11 to nn in order of input.

출력

If no correct order of operations exists, output a single word "No".

Otherwise, output a word "Yes" followed by nn distinct integers p_1,p_2,p_np\_1, p\_2, \ldots p\_n (1p_in1 \le p\_i \le n), meaning that operation p_1p\_1 should be executed first, then operation p_2p\_2, and so on. If there are several possible orders, output any of them.