#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int n) {
  long long int ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % n;
    a = (a * a) % n;
    b /= 2;
  }
  return ans;
}
unordered_map<int, int> mm;
int a[100005];
int m1[100005], m2[100005];
signed main() {
  int n, m;
  scanf("%d", &(n));
  scanf("%d", &(m));
  int flag = 0;
  memset(a, -1, sizeof a);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d", &(l));
    scanf("%d", &(r));
    scanf("%d", &(d));
    if (a[l] == -1 && a[r] == -1) {
      a[l] = 0;
      a[r] = d;
    } else if (a[l] == -1)
      a[l] = a[r] - d;
    else if (a[r] == -1)
      a[r] = a[l] + d;
    else {
      if (abs(a[l] - a[r]) != d) {
        flag = 1;
        break;
      }
    }
    m1[l] = max(a[l], m1[l]);
    m2[l] = min(a[l], m2[l]);
    m1[r] = max(a[r], m1[r]);
    m2[r] = min(a[r], m2[r]);
  }
  for (int i = 1; i <= n; i++) {
    if (m1[i] - m2[i] > 1000000000) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
