#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
  edge(int to, int cost) {
    this->to = to;
    this->cost = cost;
  }
};
const int MAX_V = 100000;
vector<edge> G[MAX_V];
int N, M;
bool visited[MAX_V];
int position[MAX_V];
bool dfs(int n, int x) {
  visited[n] = true;
  position[n] = x;
  bool isValid = true;
  for (edge e : G[n]) {
    if (visited[e.to] && position[e.to] != x + e.cost) {
      isValid = false;
    } else if (not(visited[e.to])) {
      isValid = dfs(e.to, x + e.cost);
    }
    if (not(isValid)) {
      break;
    }
  }
  return isValid;
}
int main() {
  cin >> N;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int left, right, dist;
    cin >> left;
    cin >> right;
    cin >> dist;
    left--;
    right--;
    G[left].push_back(edge(right, dist));
    G[right].push_back(edge(left, -dist));
  }
  bool isValid = true;
  for (int n = 0; n < N; n++) {
    if (not(visited[n])) {
      isValid = dfs(n, 0);
      if (not(isValid)) {
        break;
      }
    }
  }
  if (isValid) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
