#include <bits/stdc++.h>
using namespace std;
const int nmax = 100000;
struct jmek {
  int b, d;
};
int n, m;
vector<jmek> v[nmax + 5];
int P[nmax + 5];
bool cur[nmax + 5];
bool start[nmax + 5];
bool NU = 0;
void dfs(int nod) {
  if (NU == 1) return;
  cur[nod] = 1;
  for (int i = 0; i < v[nod].size(); i++) {
    int b = v[nod][i].b;
    int d = v[nod][i].d;
    if (P[b] != -2e9) {
      if (P[nod] + d != P[b]) {
        NU = 1;
        return;
      }
    }
    if (P[b]) P[b] = P[nod] + d;
    if (cur[b] == 0) dfs(b);
  }
  cur[nod] = 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) P[i] = -2e9;
  for (int i = 1; i <= m; i++) {
    int a, b, d;
    scanf("%d%d%d", &a, &b, &d);
    v[a].push_back({b, d});
    v[b].push_back({a, -d});
  }
  for (int i = 1; i <= n; i++)
    if (P[i] == -2e9 && v[i].size() >= 1) {
      P[i] = 0;
      dfs(i);
      if (NU) {
        printf("No\n");
        return 0;
      }
    }
  printf("Yes\n");
  return 0;
}
