#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"class UnionFind():\n"
"    def __init__(self,size):\n"
"        self.table=[-1]*size\n"
"    def root(self,x):\n"
"        while self.table[x]>=0:\n"
"            x=self.table[x]\n"
"        return x\n"
"    def unite(self,x,y):\n"
"        s1=self.root(x)\n"
"        s2=self.root(y)\n"
"        if s1!=s2:\n"
"            if self.table[s1]>self.table[s2]:\n"
"                s1,s2=s2,s1\n"
"            self.table[s1]+=self.table[s2]\n"
"            self.table[s2]=s1\n"
"        return\n"
"    def same(self,x,y):\n"
"        return self.root(x)==self.root(y)\n"
"    def size(self,x):\n"
"        return -self.table[self.root(x)]\n"
"n,m,*t=map(int,open(0).read().split())\n"
"u=UnionFind(n+1)\n"
"f=defaultdict(list)\n"
"e=defaultdict(list)\n"
"for l,r,d in zip(t[::3],t[1::3],t[2::3]):\n"
"    u.unite(l,r)\n"
"    e[l].append((r,d))\n"
"for i in range(n+1):\n"
"    f[u.root(i)].append(i)\n"
"for t in f.values():\n"
"    if len(t)<3:continue\n"
"    outs=defaultdict(list)\n"
"    ins=defaultdict(int)\n"
"    for i in t:\n"
"        outs[i]=[j for j,v in e[i]]\n"
"        for j in outs[i]:\n"
"            ins[j]+=1\n"
"    q=deque(v1 for v1 in t if ins[v1]==0)\n"
"    res=[]\n"
"    while q:\n"
"        v1=q.popleft()\n"
"        res.append(v1)\n"
"        for v2 in outs[v1]:\n"
"            ins[v2]-=1\n"
"            if ins[v2]==0:\n"
"                q.append(v2)\n"
"    if not res:\n"
"        print('No')\n"
"        exit()\n"
"    c=defaultdict(int)\n"
"    for i in res:\n"
"        for j,v in e[i]:\n"
"            if c[j]and c[j]!=c[i]+v:\n"
"                print('No')\n"
"                exit()\n"
"            c[j]=c[i]+v\n"
"print('Yes')\n"
"\"";
  system(s);
  return 0;
}            