#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, d;
} nd[100005 * 2];
bool cmp(node a, node b) {
  return a.l < b.l || a.l == b.l && a.r < b.r ||
         a.l == b.l && a.r == b.r && a.d < b.d;
}
int n, m;
long long a[100005];
bool vis[100005 * 2];
vector<node> adj[100005];
bool dis[100005 * 2];
void bfs(int x) {
  queue<node> que;
  memset(vis, 0, sizeof vis);
}
int main() {
  scanf("%d%d", &n, &m);
  bool flag = true;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &nd[i].l, &nd[i].r, &nd[i].d);
    if (nd[i].l > nd[i].r) {
      swap(nd[i].l, nd[i].r);
      nd[i].d = -nd[i].d;
    }
  }
  sort(nd, nd + m, cmp);
  long long ma = -0x3f3f3f3f, mi = 0x3f3f3f3f;
  for (int i = 0; i < m; i++) {
    int l = nd[i].l, r = nd[i].r, d = nd[i].d;
    if (vis[l] && vis[r]) {
      if (a[max(l, r)] - a[min(l, r)] != d) {
        flag = false;
        break;
      }
    } else {
      if (vis[l]) {
        a[r] = a[l] + d;
        vis[r] = 1;
      } else if (vis[r]) {
        a[l] = a[r] - d;
        vis[l] = 1;
      } else {
        a[l] = a[r] - d;
        vis[l] = 1;
      }
    }
    ma = max(ma, a[r]);
    ma = max(ma, a[l]);
    mi = min(mi, a[l]);
    mi = min(mi, a[r]);
  }
  if (ma - mi > (long long)1e9) flag = false;
  if (flag)
    puts("Yes");
  else
    puts("No");
  return 0;
}
