#include <bits/stdc++.h>
using namespace std;
void read(int& x) { scanf("%d", &x); }
void read(long long& x) { scanf("%lld", &x); }
template <typename T, typename... Args>
void read(T& a, Args&... b) {
  read(a);
  read(b...);
}
int base[100010];
int sa[100010];
vector<int> mem[100010];
int n, m;
int main() {
  read(n, m);
  for (int i = 1; i <= m; ++i) {
    int a, b, d;
    read(a, b, d);
    if (!base[b]) {
      if (!base[a]) {
        base[a] = a;
        sa[a] = 0;
        base[b] = a;
        sa[b] = d;
        mem[a].push_back(a);
        mem[a].push_back(b);
      } else {
        base[b] = base[a];
        sa[b] = sa[a] + d;
        mem[base[a]].push_back(b);
      }
    } else {
      if (base[a]) {
        if (base[a] == base[b]) {
          if (sa[b] - sa[a] != d) {
            puts("No");
            return 0;
          }
        } else {
          if (mem[b].size() > mem[a].size()) swap(a, b), d = -d;
          for (int first : mem[b]) {
            base[first] = base[a];
            sa[first] = sa[first] + sa[a] + d - sa[b];
          }
        }
      } else {
        base[a] = base[b];
        sa[a] = sa[b] - d;
      }
    }
  }
  puts("Yes");
  return 0;
}
