import qualified Data.IntMap as M
import Data.IntMap (IntMap)
import qualified Data.ByteString.Char 8 as B
import Data.Maybe
import Data.Bool

main :: IO ()
main = do
  [n, m] <- readIntsB
  qs <- replicateM m readIntsB
  putStr $ bool "No" "Yes" $ solve n qs

readB :: B.ByteString -> Int
readB = fst . fromJust . B.readInt

readIntsB :: IO [Int]
readIntsB = map readB . B.words <$> B.getLine

solve :: Int -> [[Int]] -> Bool
solve n qs = marge (initMap n) qs

initMap :: Int -> M.Map (M.Map Int)
initMap n = M.fromList [ (i, M.singleton i 0) | i <- [1..n] ]

marge :: IntMap (IntMap Int) -> [[Int]] -> Bool
marge _ [] = True
marge mp (q:qs)
  | indep q mp = marge (joint q mp) qs
  | margeable q mp = marge mp qs
  | otherwise = False

indep :: [Int] -> IntMap (IntMap Int) -> Bool
indep [l, r, _] mp = r `M.member` (mp ! l)

joint :: [Int] -> IntMap (IntMap Int) -> IntMap (IntMap Int)
joint [l, r, d] mp = M.insert l ml' $ M.insert r mr' $ mp
  where
    ml = mp ! l
    mr = mp ! r
    ml' = M.union ml $ M.map (+ d) mr
    mr' = M.union mr $ M.map (subtract d) ml

margeable :: [Int] -> IntMap (IntMap Int) -> Bool
margeable [l, r, d] mp = (mp ! r) ! l == d
    