#include <bits/stdc++.h>
using namespace std;
bool used[300010];
long long len[300010];
int n, m;
vector<pair<pair<int, int>, int> > v;
vector<int> S[300010];
int main() {
  scanf("%d%d", &n, &m);
  if (!m) {
    printf("Yes\n");
    return 0;
  }
  memset(len, -1ll, sizeof(len));
  int x, y, z;
  scanf("%d%d%d", &x, &y, &z);
  x--;
  y--;
  queue<int> qu;
  qu.push(x);
  qu.push(y);
  len[x] = 0;
  len[y] = 1ll * z;
  m--;
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    x--;
    y--;
    v.push_back(make_pair(make_pair(x, y), z));
    S[x].push_back(i);
    S[y].push_back(i);
  }
  int p = 0;
  while (p < m) {
    while (!qu.empty()) {
      int u = qu.front();
      qu.pop();
      for (int i = 0; i < S[u].size(); i++) {
        int j = S[u][i];
        used[j] = true;
        int x = v[j].first.first, y = v[j].first.second, z = v[j].second;
        if (len[x] == -1ll) {
          qu.push(x);
          len[x] = 1ll * len[y] - z;
        } else if (len[y] == -1ll) {
          qu.push(y);
          len[y] = 1ll * len[x] + z;
        } else if (len[y] - len[x] != (long long)(z)) {
          printf("No\n");
          return 0;
        }
      }
    }
    while (p < m && used[p]) p++;
    if (p < m) {
      used[p] = true;
      qu.push(v[p].first.first);
      qu.push(v[p].first.second);
      len[v[p].first.first] = 0ll;
      len[v[p].first.second] = 1ll * v[p].second;
      p++;
    }
  }
  printf("Yes\n");
  return 0;
}
