Indra is excited, because they have just learned Haskell! Now that they have acquired the skills of a functional programming god, they want to start working on a project made of nn tasks. There are mm ways to move between tasks while working: each move goes from some task aa to another task bb and changes Indra's productivity by an integer cc. Positive values help; negative values represent fighting compiler errors.

Indra can start at any task and keep following moves, possibly using the same move more than once. Josh has claimed that no matter how Indra works, they can never return to a previously visited task with a strictly positive total productivity change along the way. In other words, Josh claims there is no productive loop in the project.

Help Indra check whether Josh is wrong.

A move from a task to itself counts as a loop. There may be several different moves between the same pair of tasks.

Input

The first line contains two integers nn and mm.

The next mm lines each contain three integers aa, bb, and cc, describing a move from task aa to task bb that changes productivity by cc.

Tasks are numbered 11 through nn.

Output

Print YES if there exists a sequence of moves that starts and ends at the same task and has strictly positive total productivity change. Otherwise, print NO.

Constraints

  • 1n10001 \le n \le 1000
  • 0m100000 \le m \le 10000
  • 1a,bn1 \le a, b \le n
  • 100c100-100 \le c \le 100

Example 1

Input 1
3 6
3 1 -80
1 3 -58
1 3 81
2 3 -81
2 1 24
2 1 -55
Output 1
YES
Explanation

Starting at task 11, Indra can move 131 \to 3 with productivity 8181, then 313 \to 1 with productivity 80-80, returning to task 11 with total change 11.

Example 2

Input 2
2 2
1 2 10
2 1 -10
Output 2
NO
Explanation

The only way to return to the starting task has total productivity change 00, which is not strictly positive.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.