import qualified Data.ByteString.Char8 as BC
import qualified Data.IntMap as M
import Data.Maybe (fromJust)
import Data.List
import Data.Array.IO
import Control.Monad

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  info <- map (\[x,y,z] -> (x,y,z)) <$> getInt2DListBC
  if solve M.empty info
    then putStrLn "Yes"
    else putStrLn "No"

type EdgeW = (Int, Int, Int)
type Weight = Int
type Vertex = (Int, Weight)
type GraphW = M.IntMap Neighbor
type Neighbor = M.IntMap Weight

solve :: GraphW -> [EdgeW] -> Bool
solve _     []             = True
solve graph ((l, r, d):es) =
  let fl = check graph (l, r, d)
      fr = check graph (r, l, 0-d)
  in if fl && fr
       then let g = register graph (l, r, d)
                g' = register g (r, l, 0-d)
            in solve g' es
       else False

check :: GraphW -> EdgeW -> Bool
check graph (l, r, d) =
  let nL = M.lookup l graph
  in if nL == Nothing
    then True
    else let nL' = fromJust nL
             nR = M.lookup r nL'
         in if nR == Nothing
              then True
              else fromJust nR == d

register :: GraphW -> EdgeW -> GraphW
register graph (l, r, d) =
  let nL = M.lookup l graph
  in if nL == Nothing
       then makeGraphW graph (l, r, d)
       else foldl (register' (l, r, d)) graph $ M.toList . fromJust $ nL

register' :: EdgeW -> GraphW -> (Int, Int) -> GraphW
register' (l, r, d) graph (to, dist) =
  makeGraphW graph (r, to, dist - d)

--重み付き隣接リスト
makeGraphW :: GraphW -> EdgeW -> GraphW
makeGraphW graph (x, y, w) =
  let nX = M.lookup x graph
      nY = M.lookup y graph
      vX = if nX == Nothing
             then M.insert x (addNeighbor (y, w) M.empty) graph
             else M.insert x (addNeighbor (y, w) $ fromJust nX) graph
  in if nY == Nothing
       then M.insert y (addNeighbor (x, 0-w) M.empty) vX
       else M.insert y (addNeighbor (x, 0-w) $ fromJust nY) vX

addNeighbor :: Vertex -> Neighbor -> Neighbor
addNeighbor (i, weight) ne = M.insert i weight ne

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents
