local n, m = io.read("*n", "*n")
local edge = {}
local pos = {}
for i = 1, n do
  edge[i] = {}
  pos[i] = false
end
for i = 1, m do
  local l, r, d = io.read("*n", "*n", "*n")
  edge[l][r] = d
  edge[r][l] = -d
end
local f = true
local function solve(start)
  local tasks = {start}
  if not pos[start] then pos[start] = 0 end
  while 0 < #tasks do
    local src = tasks[#tasks]
    table.remove(tasks)
    for dst, len in pairs(edge[src]) do
      if pos[dst] then
        if pos[dst] ~= pos[src] + len then
          f = false
          break
        end
      else
        pos[dst] = pos[src] + len
        edge[dst][src] = nil
        table.insert(tasks, dst)
      end
    end
    edge[src] = {}
    if not f then break end
  end
end

for i = 1, n do
  solve(i)
  if not f then break end
end
print(f and "Yes" or "No")
