local ior = io.input()
local n, m = ior:read("*n", "*n")
local hasinfo = {}
local pos = {}
local parent = {}
for i = 1, n do parent[i] = i end
for i = 1, n do hasinfo[i], pos[i] = false, 0 end
local isok = true

function getroot(idx)
  while(parent[idx] ~= idx) do
    idx = parent[idx]
  end
  return idx
end

for i = 1, m do
  local l, r, d = ior:read("*n", "*n", "*n")
  if(isok) then
    local lr, rr = getroot(l), getroot(r)
    parent[l], parent[r], parent[rr] = lr, lr, lr
    if(hasinfo[l] and hasinfo[r]) then
      isok = (d == pos[r] - pos[l])
    elseif(hasinfo[l]) then
      hasinfo[r] = true
      pos[r] = pos[l] + d
    elseif(hasinfo[r]) then
      hasinfo[l] = true
      pos[l] = pos[r] - d
    else
      hasinfo[l], hasinfo[r] = true, true
      pos[l] = 0
      pos[r] = d
    end
  end
end
if(isok) then
  local parents = {}
  for i = 1, n do
    local root = getroot(i)
    if(parents[root] == nil) then
      parents[root] = {}
      parents[root].min = pos[i]
      parents[root].max = pos[i]
    else
      parents[root].min = math.min(parents[root].min, pos[i])
      parents[root].max = math.max(parents[root].max, pos[i])
    end
  end
  for p, val in pairs(parents) do
    if(1000000000 < val.max - val.min) then
      isok = false
      break
    end
  end
end
print(isok and "Yes" or "No")
