Edge Coloring

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

문제

You are given a simple connected undirected graph with NN vertices and MM edges. The ii-th edge connects the vertices a_ia\_i and b_ib\_i.

Initially, the edges are not colored. Takahashikun wants to color the ii-th edge with the color c_ic\_i.

He can color the edges in the following way:

  • First he chooses a vertex, and he repeats zero or more steps.
  • In each step, he chooses a vertex adjacent to the current vertex and moves to the chosen vertex along an edge. This edge is colored red or blue (the color is defined according to the rule below).
  • In odd-indexed (1-based) steps he uses red. In even-indexed steps he uses blue.
  • If he colors an already-colored edges, the color of the edge is updated to the new color.

Determine if he can color all edges with correct colors.

입력

NN MM
a_1a\_1 b_1b\_1 c_1c\_1
a_2a\_2 b_2b\_2 c_2c\_2
\vdots
a_Ma\_M b_Mb\_M c_Mc\_M

출력

Print "Yes", if Takahashikun can color all edges with correct colors or "No" otherwise.

제한

  • 2N20002 \leq N \leq 2000
  • 1M20001 \leq M \leq 2000
  • 1a_i<b_iN1 \leq a\_i < b\_i \leq N
  • The pairs (a_i,b_i)(a\_i, b\_i) are pairwise distinct.
  • c_ic\_i is either an 'r' (red) or a 'b' (blue).
  • The graph is connected.