import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		
		DisjointSet joint = new DisjointSet(n);
		
		Info info[] = new Info[m];
		ArrayList<Info> list = new ArrayList<Info>();
		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			info[i] = new Info(Integer.parseInt(tmpArray[0]), 
					Integer.parseInt(tmpArray[1]), 
					Integer.parseInt(tmpArray[2])
					);
			
			joint.union(info[i].l, info[i].r);
			
			list.add(info[i]);
		}
		
		//Arrays.sort(info);
		Collections.sort(list);
		
		Person[] people = new Person[n];
		for(int i = 0; i < n; i++){
			people[i] = new Person();
		}
		
		boolean available = true;
//		for(int i = 0; i < m; i++){
		
		int prev = -1;
		while(!list.isEmpty()){
			Info tmpInfo = list.get(0);
//			Person p1 = people[info[i].l - 1];
//			Person p2 = people[info[i].r - 1];
//			int d = info[i].d;
			Person p1 = people[tmpInfo.l - 1];
			Person p2 = people[tmpInfo.r - 1];
			int d = tmpInfo.d;

			//どちらも未確定
			if(!p1.fixed && !p2.fixed){
				if(prev >= 0 && joint.isSameSet(prev, tmpInfo.l)){
					list.add(tmpInfo);
				}
				else {
					p1.setPos(0);
					p2.setPos(d);
				}
			}
			//p1だけ確定
			else if(!p2.fixed){
				p2.setPos(p1.pos + d);
			}
			//p2だけ確定
			else if(!p1.fixed){
				p1.setPos(p2.pos + d);
			}
			//両方とも確定（矛盾チェック）
			else {
				if(p1.pos + d != p2.pos){
					available = false;
					break;
				}
			}
			
			prev = tmpInfo.l;
			list.remove(0);
			
		}
		
		if(available){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}

}

class DisjointSet {
    private int n;
    private int[] p;
    private int[] rank;
 
    public DisjointSet(int n){
        this.n = n;
 
        p = new int[n + 1];
        rank = new int[n + 1];
 
        for(int i = 1; i <= n; i++){
            makeSet(i);
        }
    }
 
    private void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
 
    public void union(int x, int y){
        link (findSet(x), findSet(y));
    }
 
    private int findSet(int x){
        if(x != p[x]){
            p[x] = findSet( p[x]);
        }
        return p[x];
    }
 
    public boolean isSameSet(int x, int y){
        return findSet(x) == findSet(y);
    }
 
    private void link(int x, int y){
        if(rank[x] > rank[y]){
            p[y] = x;
        }
        else {
            p[x] = y;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
}

class Person {
	boolean fixed = false;
	long pos = Long.MIN_VALUE;
	
	public void setPos(long pos){
		fixed = true;
		this.pos = pos;
	}
}

class Info implements Comparable<Info>{
	int l;
	int r;
	int d;
	
	public Info (int l, int r, int d){
//		if(l <= r){
		if(true){
			this.l = l;
			this.r = r;
			this.d = d;
		}
		else {
			this.l = r;
			this.r = l;
			this.d = -d;
		}
	}

	@Override
	public int compareTo(Info info) {
		// TODO Auto-generated method stub
		return this.l == info.l ? (this.r - info.r) : this.l - info.l;
	}
}