#include <bits/stdc++.h>
using namespace std;
using LL = long long;
struct point {
  int to, cost;
};
vector<point> a[100001];
int N, M;
int dis[100001];
bool check[100001];
bool solve(int start) {
  memset(dis, -1, sizeof(int) * 100001);
  queue<int> que;
  dis[start] = 0;
  que.push(start);
  while (!que.empty()) {
    int now = que.front();
    que.pop();
    check[now] = true;
    for (point elm : a[now]) {
      if (dis[elm.to] == -1) {
        dis[elm.to] = elm.cost + dis[now];
        que.push(elm.to);
      } else {
        if (dis[elm.to] != elm.cost + dis[now]) {
          return false;
        }
      }
    }
  }
  return true;
}
int main(void) {
  bool ans = true;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int r, l, d;
    scanf("%d %d %d", &r, &l, &d);
    point s = {l, d};
    a[r].push_back(s);
    s = {r, -1 * d};
    a[l].push_back(s);
  }
  for (int i = 1; i < N + 1; i++) {
    if (!check[i]) {
      if (solve(i)) {
        continue;
      } else {
        ans = false;
        break;
      }
    }
  }
  if (ans) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
