#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXLOG = 17;
vector<int> G[MAXN], GW[MAXN];
int N, M, dsu[MAXN];
inline int find(int x) { return (x == dsu[x]) ? x : (dsu[x] = find(dsu[x])); }
struct item {
  int u, v, d;
} A[MAXM];
int NA = 0;
bool vis[MAXN];
int val[MAXN];
void dfs(int u, int f) {
  int i, v;
  for (i = 0; i < G[u].size(); i++)
    if ((v = G[u][i]) != f) {
      val[v] = val[u] + GW[u][i];
      dfs(v, u);
    }
}
int main() {
  int i, u, v, d;
  scanf("%d%d", &N, &M);
  for (i = 1; i <= N; i++) dsu[i] = i;
  for (i = 1; i <= M; i++) {
    scanf("%d%d%d", &u, &v, &d);
    int pu = find(u), pv = find(v);
    if (pu != pv) {
      dsu[pu] = pv;
      G[u].push_back(v), GW[u].push_back(d);
      G[v].push_back(u), GW[v].push_back(-d);
    } else
      A[++NA] = (item){u, v, d};
  }
  for (i = 1; i <= N; i++)
    if (!vis[i]) dfs(i, 0);
  for (i = 1; i <= NA; i++) {
    int dis = val[A[i].v] - val[A[i].u];
    if (dis != A[i].d) {
      printf("No");
      return 0;
    }
  }
  printf("Yes");
}
