#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e5;
void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<vector<pair<int, int>>> adj;
bool vis[N];
int dist[N];
bool f = true;
void dfs(int cur_node) {
  vis[cur_node] = 1;
  for (int i = 0; i < adj[cur_node].size(); i++) {
    auto child = adj[cur_node][i];
    if (!vis[child.first]) {
      if (dist[cur_node])
        dist[child.first] += dist[cur_node] + child.second;
      else {
        dist[cur_node] = child.second;
        dist[child.first] += dist[cur_node];
      }
      dfs(child.first);
    } else {
      if (dist[child.first] != child.second && dist[child.first]) {
        f = false;
        return;
      } else {
        if (dist[cur_node])
          dist[child.first] += dist[cur_node] + child.second;
        else {
          dist[cur_node] = child.second;
          dist[child.first] += dist[cur_node];
        }
        dfs(child.first);
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  adj = vector<vector<pair<int, int>>>(n + 1);
  for (int i = 0; i < m; i++) {
    int f, t, w;
    scanf("%d%d%d", &f, &t, &w);
    adj[f].push_back({t, w});
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      if (!f) {
        puts("No");
        break;
      }
    }
  }
  if (f) puts("Yes");
  return 0;
}
