#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int read_ll() {
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  int ret = 0;
  int neg = 0;
  if (c == '-') neg = 1, c = getchar();
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return neg ? -ret : ret;
}
const int N = 1e5 + 5;
map<pair<int, int>, int> dist;
int n;
vector<int> g[N];
int val[N];
bool visited[N];
void make_set(vector<int>& rank, vector<int>& id, int n) {
  for (int i = 1; i <= n; i++) rank[i] = 1, id[i] = i;
}
int find_set(vector<int>& id, int p) {
  int child = p;
  while (id[p] != p) {
    p = id[p];
  }
  while (child != p) {
    int newchild = id[child];
    id[child] = p;
    child = newchild;
  }
  return p;
}
int merge_set(vector<int>& rank, vector<int>& id, int u, int v) {
  int rootu = find_set(id, u);
  int rootv = find_set(id, v);
  if (rank[rootu] > rank[rootv])
    id[rootv] = rootu, rank[rootu] += rank[rootv];
  else
    id[rootu] = rootv, rank[rootv] += rank[rootu];
}
void dfs(int u, int p) {
  if (visited[u]) return;
  visited[u] = true;
  for (auto v : g[u]) {
    if (v == p) continue;
    val[v] = val[u] + dist[make_pair(u, v)];
    dfs(v, u);
  }
}
int main() {
  int qq;
  cin >> n >> qq;
  vector<int> rank(n + 1), id(n + 1);
  vector<pair<pair<int, int>, int> > q(n + 1);
  make_set(rank, id, n);
  memset(val, 0, sizeof(val));
  memset(g, 0, sizeof(g));
  memset(visited, 0, sizeof(visited));
  for (int i = 1; i <= qq; i++) {
    cin >> q[i].first.first >> q[i].first.second >> q[i].second;
    dist[make_pair(q[i].first.first, q[i].first.second)] = q[i].second;
    int fu = find_set(id, q[i].first.first);
    int fv = find_set(id, q[i].first.second);
    if (fu != fv) {
      merge_set(rank, id, q[i].first.first, q[i].first.second);
      g[q[i].first.first].push_back(q[i].first.second);
    }
  }
  int k = 1;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) val[i] = k++, dfs(i, -1);
  }
  for (int i = 1; i <= qq; i++) {
    if (val[q[i].first.second] - val[q[i].first.first] != q[i].second) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
