import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad
import Control.Monad.ST
import Debug.Trace

traceQ :: (Show a) => String -> a -> a
-- traceQ label a = trace (label ++ ": " ++ show a) a
traceQ _ a = a

traceZ :: String -> a -> a
-- traceZ = trace
traceZ _ a = a

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve :: Int -> Int -> [[Int]] -> Bool
solve valN valM lrds = runST (act valN valM lrds)

act :: Int -> Int -> [[Int]] -> ST s Bool
act valN valM lrds = do
  vec <- VM.replicate (valN+1) (-1,-1)
  act1 lrds vec

act1 :: [[Int]] -> VM.MVector s (Int, Int) -> ST s Bool
act1 [] _ = return True
act1 ([l,r,d]:lrds) vec = do
  b <- step l r d vec
  if b
    then act1 lrds vec
    else return False

step :: Int -> Int -> Int -> VM.MVector s (Int, Int) -> ST s Bool
step l r d vec = do
  (prevL, distL) <- VM.read vec l
  (prevR, distR) <- VM.read vec r
  if distR == -1
    then do
    when (distL == -1) (VM.write vec l (-1, 0))
    VM.write vec (traceZ (show "A " ++ show r ++ "," ++ show l ++ "," ++ show d) r) (l, d)
    return True
    else
    if distL == -1
    then do
      VM.write vec (traceZ (show "B " ++ show l ++ "," ++ show r ++ "," ++ show (-d)) l) (r, -d)
      -- VM.write vec l (r, -d)
      return True
    else do
      (lTop, lTopDist) <- findTop vec l 
      (rTop, rTopDist) <- findTop vec r
      if lTop == rTop
        then
        if lTopDist + d == rTopDist
        then
          return True
        else
          return False
        else do
        VM.write vec rTop (lTop, lTopDist + d - rTopDist)
        return True

findTop :: VM.MVector s (Int, Int) -> Int -> ST s (Int, Int)
findTop vec x = ftsub 0 vec x
  where
    ftsub acc vec x = do
      (prev, dist) <- VM.read vec x
      if prev == -1 then return (x, acc)
        else ftsub (acc + dist) vec prev
        

main :: IO ()
main = do
  conts <- B.getContents
  let [valN, valM] : lrds = map bsReadInts (B.lines conts)
      answer = solve valN valM lrds
  putStrLn (if answer then "Yes" else "No")
