#include <bits/stdc++.h>
using namespace std;
struct report {
  int left, right;
  long distance;
};
struct road {
  int goal;
  long distance;
};
vector<int> parents;
int find_root(int now) {
  if (parents[now] == now) {
    return now;
  } else {
    int ans = find_root(parents[now]);
    parents[now] = ans;
    return ans;
  }
}
vector<vector<int>> roots;
vector<vector<road>> roads;
vector<long> distances;
void find_error(int now) {
  for (int i = 0; i < roads[now].size(); i++) {
    if (distances[roads[now][i].goal] > 1e15) {
      distances[roads[now][i].goal] = distances[now] + roads[now][i].distance;
    } else if (distances[roads[now][i].goal] !=
               distances[now] + roads[now][i].distance) {
      cout << "No" << endl;
      exit(0);
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    parents.push_back(i);
  }
  report reports[M];
  roads.resize(N);
  for (int i = 0; i < M; i++) {
    cin >> reports[i].left >> reports[i].right >> reports[i].distance;
    parents[find_root(reports[i].left - 1)] = find_root(reports[i].right - 1);
    roads[reports[i].left - 1].push_back(
        {reports[i].right - 1, reports[i].distance});
    roads[reports[i].right - 1].push_back(
        {reports[i].left - 1, -reports[i].distance});
  }
  roots.resize(N);
  for (int i = 0; i < N; i++) {
    roots[find_root(i)].push_back(i);
  }
  vector<report> reports_group[N];
  for (int i = 0; i < M; i++) {
    reports_group[find_root(reports[i].left - 1)].push_back(reports[i]);
  }
  distances.resize(N);
  fill(distances.begin(), distances.end(), 1e16);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < N; j++) {
      if (roots[j].size()) {
        distances[roots[j][0]] = 0;
      }
      for (int k = 0; k < roots[j].size(); k++) {
        find_error(roots[j][k]);
      }
      long max_position = 0, min_position = 0;
      for (int k = 0; k < roots[j].size(); k++) {
        max_position = max(max_position, distances[roots[j][k]]);
        min_position = min(max_position, distances[roots[j][k]]);
      }
    }
  }
  cout << "Yes" << endl;
}
