#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
vector<vector<PII> > G, G1;
bool visited[100004], visited1[100005], root[100005];
int dist[100005];
bool fail;
int dfs(int v) {
  if (visited[v]) return 0;
  if (((int)(G[v]).size()) == 0) {
    root[v] = 1;
    return v;
  }
  visited[v] = true;
  for (auto p : G[v]) {
    int k = dfs(p.first);
    if (k != 0) return k;
  }
  return 0;
}
void dfs1(int v) {
  if (visited1[v]) return;
  visited1[v] = true;
  for (auto p : G1[v]) {
    if (dist[p.first] != -1) {
      if (dist[p.first] != dist[v] + p.second) {
        fail = true;
        return;
      }
    } else {
      dist[p.first] = dist[v] + p.second;
      dfs1(p.first);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int N, M;
  cin >> N >> M;
  G.assign(N + 3, vector<PII>());
  G1.assign(N + 3, vector<PII>());
  for (int _n = M, i = 0; i < _n; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    G[r].push_back({l, d});
    G1[l].push_back({r, d});
  }
  for (int i = (1), _b = (N); i <= _b; ++i) {
    if (!visited[i]) {
      int k = dfs(i);
      if (!k) {
        root[i] = true;
      }
    }
  }
  memset(dist, -1, sizeof(dist));
  for (int i = (1), _b = (N); i <= _b; ++i) {
    if (root[i]) {
      dist[i] = 0;
      dfs1(i);
    }
    if (fail) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}
