#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::fill;
using std::lower_bound;
using std::pair;
using std::priority_queue;
using std::queue;
using std::set;
using std::sort;
using std::stack;
using std::string;
using std::upper_bound;
using std::vector;
const int maxn = 100000 + 100;
int fa[maxn];
int dis[maxn];
int n, m;
void init() {
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    dis[i] = 0;
  }
}
int findfa(int x) {
  if (fa[x] == x) return x;
  int t = fa[x] = findfa(fa[x]);
  dis[x] += dis[t];
  return fa[x];
}
bool link(int x, int y, int d) {
  if (findfa(x) == findfa(y))
    if (dis[y] - dis[x] == d)
      return true;
    else
      return false;
  else {
    dis[fa[y]] = d - dis[y] + dis[x];
    fa[fa[y]] = findfa(x);
    return true;
  }
}
int main(int argc, char** argv) {
  if (argc == 2 && strcmp(argv[1], "-debug") == 0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  cin >> n >> m;
  init();
  bool ans = true;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    if (!link(a, b, c)) {
      ans = false;
      break;
    }
  }
  if (ans)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
