#include <bits/stdc++.h>
using namespace std;
using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;
const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
template <class T>
void Printnector(const vector<T> &v) {
  for (const auto &e : v) {
    cout << e << endl;
  }
}
template <class T>
void Printnector(const vector<T> &v, unsigned n) {
  for (long i = (0); i <= (n - 1); ++i) {
    cout << v[i] << endl;
  }
}
enum class Color {
  kWhite,
  kGrey,
  kBlack,
};
struct Edge {
  using w_type = int;
  Edge(int u, int v, w_type w) : u(u), v(v), w(w) {}
  int u, v;
  w_type w;
  bool operator<(const Edge &rhs) const {
    if (w != rhs.w) {
      return w < rhs.w;
    }
    if (u != rhs.u) {
      return u < rhs.u;
    }
    return v < rhs.v;
  }
};
const int kNil = -1;
VI d(100005, 0);
vector<vector<Edge>> adjacency_list(100005, vector<Edge>());
vector<Color> color(100005, Color::kWhite);
vector<int> parent(100005, kNil);
bool DFSVisit(const int node_now) {
  color[node_now] = Color::kGrey;
  for (const auto &e : adjacency_list[node_now]) {
    if (color[e.v] != Color::kWhite && d[e.v] != d[node_now] + e.w) {
      return false;
    }
    if (color[e.v] == Color::kWhite) {
      d[e.v] += d[node_now] + e.w;
      DFSVisit(e.v);
    }
  }
  color[node_now] = Color::kBlack;
  return true;
}
int main(int argc, char const *argv[]) {
  using w_type = int;
  vector<Edge> edges;
  unsigned n, m;
  cin >> n >> m;
  for (unsigned i = 0; i < m; ++i) {
    unsigned u, v;
    w_type w;
    cin >> u >> v >> w;
    edges.emplace_back(u, v, w);
    edges.emplace_back(v, u, -w);
  }
  for (const auto &e : edges) {
    adjacency_list[e.u].push_back(e);
  }
  for (unsigned i = 0; i < n; ++i) {
    if (color[i] == Color::kWhite) {
      d[i] = 0;
      if (!DFSVisit(i)) {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
