{-# OPTIONS_GHC -O #-}

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

main = do
    (n:m:_)<-map read.words<$>getLine::IO [Int]
    lrds <- replicateM m $ unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine :: IO[[Int]]
    --
    let res = solve n lrds
--    case res of
--        Nothing -> return ()
--        Just (uf,dt) -> print uf >> print dt
    --
    putStrLn $ case res of
        Nothing -> "No"
        Just (uf, dt) | chk uf dt -> "Yes"
        _ -> "No"
--
chk uf dt = all (\(a,b) -> (b-a) <= 1000000000) $ M.elems md
    where
        md = foldl (\m i -> M.alter (mf (dt V.! i)) (uf V.! i) m) M.empty [1..V.length uf-1]
        mf d Nothing = Just (min 0 d, max 0 d)
        mf d (Just (a,b)) = Just (min a d, max b d)
--
solve :: Int -> [[Int]] -> Maybe (V.Vector Int, V.Vector Int)
solve n lrds = runST $ do
    uf <- VM.replicate (n+1) (-1) :: ST s (VM.STVector s Int)
    dt <- VM.replicate (n+1) 0 :: ST s (VM.STVector s Int)
    --
    ins uf dt lrds
--
ins uf dt [] = do
    forM_ [1..VM.length uf-1] $ findUF uf dt
    forM_ [1..VM.length uf-1] $ \i -> do
        p <- VM.unsafeRead uf i
        when (p == (-1)) $ VM.unsafeWrite uf i i
    uf' <- V.freeze uf
    dt' <- V.freeze dt
    return $ Just (uf',dt')

ins uf dt ((l:r:d:_):lrds) = do
    (lp,ld) <- findUF uf dt l
    (rp,rd) <- findUF uf dt r
    case (lp,rp) of
        (a,b) | a/=b -> VM.unsafeWrite uf r l >> VM.unsafeWrite dt r (d-rd) >> ins uf dt lrds
        (a,b) | rd-ld == d -> ins uf dt lrds
        _ -> return Nothing

--
findUF :: VM.STVector s Int -> VM.STVector s Int -> Int -> ST s (Int,Int)
findUF uf dt x = do
    p <- VM.unsafeRead uf x
    d <- VM.unsafeRead dt x
    if p == -1
        then return (x,0)
        else do
                (f,v) <- findUF uf dt p
                VM.unsafeWrite uf x f
                VM.unsafeWrite dt x (d+v)
                return (f,d+v)