#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 1 << 17;
using namespace std;
long long int dy[] = {0, 0, 1, -1, 0};
long long int dx[] = {1, -1, 0, 0, 0};
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
struct aaa {
  aaa() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} aaaaaaa;
long long int par[100001];
long long int trank[100001];
void init(long long int n) {
  for (long long int i = 0; i < n; i++) {
    par[i] = i;
    trank[i] = 0;
  }
}
long long int find(long long int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
  return 0;
}
void unite(long long int x, long long int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (trank[x] < trank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (trank[x] == trank[y]) trank[x]++;
  }
}
bool same(long long int x, long long int y) { return find(x) == find(y); }
signed main() {
  long long int n, m;
  cin >> n >> m;
  init(n);
  std::map<long long int, long long int> check;
  std::vector<std::vector<long long int>> query(m,
                                                std::vector<long long int>(3));
  for (long long int i = 0; i < m; i++) {
    cin >> query[i][0] >> query[i][1] >> query[i][2];
    unite(query[i][0], query[i][1]);
  }
  for (long long int i = 0; i < 2 * m; i++) {
    long long int l = query[i % m][0];
    long long int r = query[i % m][1];
    long long int d = query[i % m][2];
    if (check.count(l) == 0 && check.count(r) == 0) {
      if (par[l] == l) {
        check[l] = 0;
        check[r] = d;
      } else if (par[r] == r) {
        check[l] = -d;
        check[r] = 0;
      } else {
        continue;
      }
    } else if (check.count(r) == 0) {
      check[r] = check[l] + d;
    } else if (check.count(l) == 0) {
      check[l] = check[r] - d;
    } else if (check[r] - check[l] != d) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
