#include <bits/stdc++.h>
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
void mkuni(vector<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T>
void print(T x, int suc = 1) {
  cout << x;
  if (suc == 1)
    cout << '\n';
  else
    cout << ' ';
}
template <class T>
void print(const vector<T>& v, int suc = 1) {
  for (int i = 0; i < v.size(); i++)
    print(v[i], i == (int)(v.size()) - 1 ? suc : 2);
}
struct Edge {
  int to, w;
};
const int maxn = 1e5 + 7;
vc<Edge> G[maxn];
inline void addedge(int u, int v, int w) {
  G[v].push_back(Edge{u, w});
  G[u].push_back(Edge{v, -w});
}
int cnt[maxn];
int n, m;
int dis[maxn];
bool inq[maxn];
bool vis[maxn];
bool spfa(int st) {
  queue<int> q;
  q.push(st);
  dis[st] = 0;
  while (!q.empty()) {
    auto u = q.front();
    q.pop();
    vis[u] = 1;
    inq[u] = 0;
    for (auto& e : G[u]) {
      int v = e.to;
      if (dis[v] > dis[u] + e.w) {
        dis[v] = dis[u] + e.w;
        cnt[v] = cnt[u] + 1;
        if (cnt[v] > n) return false;
        if (!inq[v]) {
          inq[v] = 1;
          q.push(v);
        }
      }
    }
  }
  return true;
}
bool solve() {
  memset(dis, 0x3f, sizeof(dis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && !spfa(i)) return false;
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0, u, v, w; i < m; i++) {
    cin >> u >> v >> w;
    addedge(u, v, w);
  }
  if (solve())
    cout << "Yes\n";
  else
    cout << "No\n";
}
