{-# OPTIONS_GHC -O #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Control.Monad.ST
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import qualified Data.Sequence as SQ
import Data.Sequence ((|>), (<|), ViewL(..), ViewR(..))

main = do
    (n:m:_)<-map read.words<$>getLine::IO [Int]
    lrds <- replicateM m $ unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine :: IO[[Int]]
    --
    let grp = foldl (\m (l:r:d:_)->M.alter (ins l (-d)) r $ M.alter (ins r d) l m) M.empty lrds
    --
--    print $ map (\(l:r:d:_)->chk n grp l r d) lrds
    putStrLn $ if all (\(l:r:d:_) -> chk n grp l r d) lrds then "Yes" else "No"
--
ins ::Int -> Int -> Maybe [(Int,Int)] -> Maybe [(Int,Int)]
ins n w Nothing = Just [(n,w)]
ins n w (Just nws) = Just ((n,w):nws)
--
chk :: Int -> M.IntMap [(Int,Int)] -> Int -> Int -> Int -> Bool
chk n grp l r d = path d n grp l r
--
path d n grp l r = runST $ do
    nf <- VM.replicate n False :: ST s (VM.STVector s Bool)
    dfs d grp r nf $ SQ.singleton (l,0)
--
dfs :: Int -> M.IntMap [(Int,Int)] -> Int -> VM.STVector s Bool -> SQ.Seq (Int,Int) -> ST s Bool
dfs _ _ _ _  (SQ.viewl -> SQ.EmptyL) = return True
dfs d grp r nf (SQ.viewl -> (n,w) :< q) =
    if n==r
        then if d==w then dfs d grp r nf q else return False
        else do
            f <- VM.unsafeRead nf n
            VM.unsafeWrite nf n True
            if f
                then dfs d grp r nf q
                else dfs d grp r nf $ foldl (flip (<|)) q $ map (\(a,b)->(a,b+w)) (grp M.! n)
