#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int last[2 * maxn], pre[2 * maxn], other[2 * maxn];
long long cost[2 * maxn], dis[maxn];
bool vis[maxn], vis1[2 * maxn];
int que[maxn];
int all = -1;
void build(int x, int y, long long z) {
  pre[++all] = last[x];
  last[x] = all;
  other[all] = y;
  cost[all] = z;
}
bool dfs(int x) {
  vis[x] = 1;
  int dt = last[x];
  while (dt != -1) {
    int dr = other[dt];
    if (vis1[dt] == 0) {
      vis1[dt] = 1;
      if (vis[dr] == 0) {
        dis[dr] = dis[x] + cost[dt];
      }
      if (vis[dr] == 1) {
        if (dis[dr] != dis[x] + cost[dt]) return false;
      }
      if (!dfs(dr)) return false;
    }
    dt = pre[dt];
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  memset(last, -1, sizeof(last));
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long z;
    cin >> x >> y >> z;
    if (vis[x] == 0) vis[x] = 1, que[++cnt] = x;
    if (vis[y] == 0) vis[y] = 1, que[++cnt] = y;
    build(x, y, z);
    build(y, x, -z);
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= cnt; i++) {
    if (vis[que[i]] == 0) {
      dis[que[i]] = 0;
      if (dfs(que[i]) == false) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
