#include <bits/stdc++.h>
using namespace std;
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int n, m;
int l, r, d;
vector<pair<int, int> > adj[MAX];
vector<int> lmost;
int lft[MAX];
int rgt[MAX];
int coor[MAX];
bool flag = true;
void dfs(int s) {
  for (int i = 0; i < (int)adj[s].size(); i++) {
    int v = adj[s][i].first;
    int d = adj[s][i].second;
    if (coor[v] == -1)
      coor[v] = coor[s] + d;
    else if (coor[v] != coor[s] + d) {
      flag = false;
      return;
    }
    dfs(v);
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &d);
    lft[r]++;
    rgt[l]++;
    adj[l].push_back(make_pair(r, d));
  }
  if (m == 0) {
    printf("Yes");
    return 0;
  }
  for (int i = 1; i <= n; i++) coor[i] = -1;
  for (int i = 1; i <= n; i++) {
    if (lft[i] == 0 && rgt[i] > 0) lmost.push_back(i);
  }
  if (lmost.size() == 0) {
    printf("No");
    return 0;
  } else {
    for (int i = 1; i < (int)lmost.size(); i++) {
      coor[lmost[i]] = 0;
    }
    for (int i = 0; i < (int)lmost.size(); i++) {
      dfs(lmost[i]);
      if (!flag) break;
    }
  }
  if (flag)
    printf("Yes");
  else
    printf("No");
  return 0;
}
