#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100, M = 1e3, LG = 30, base = 2;
const int MOD = 1e9 + 7, mod = 1e9 + 9;
const long long INF = 1e9, inf = 1e18;
long long n, m, v, u, d, pos[N], head[N], x, y, k;
vector<pair<long long, long long> > w[N];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    pos[i] = 0, head[i] = i;
    w[i].push_back(make_pair(0, i));
  }
  for (int i = 0; i < m; i++) {
    cin >> v >> u >> d;
    if (head[v] == head[u] &&
        w[head[v]][pos[v]].first - w[head[u]][pos[u]].first != d)
      return cout << "No", 0;
    else {
      x = head[v], y = head[u];
      if (w[x].size() < w[y].size()) {
        k = w[y][pos[u]].first - w[x][pos[v]].first + d;
        while (w[x].size() > 0) {
          pos[w[x].back().second] = w[y].size();
          head[w[x].back().second] = y;
          w[y].push_back(make_pair(w[x].back().first + k, w[x].back().second));
          w[x].pop_back();
        }
      } else {
        k = w[x][pos[v]].first - w[y][pos[u]].first - d;
        while (w[y].size() > 0) {
          pos[w[y].back().second] = w[x].size();
          head[w[y].back().second] = x;
          w[x].push_back(make_pair(w[y].back().first + k, w[y].back().second));
          w[y].pop_back();
        }
      }
    }
  }
  cout << "Yes";
  return 0;
}
