#include <bits/stdc++.h>
using namespace std;
long long inf = 2147483647;
const long long ll = 9223372036854775807, ninf = 1000000000;
const double eps = 1e-6;
const long long nll = 1000000000000000000;
class MagicNumberThree {
 public:
  int countSubsequences(string s) {}
};
int vis[100005] = {};
int val[100005] = {};
int find(int x) {
  if (x == vis[x]) {
    return x;
  } else {
    int tmp = vis[x];
    vis[x] = find(x);
    val[x] += val[tmp];
    return vis[x];
  }
}
int main() {
  int a, b;
  while (cin >> a >> b) {
    for (int i = 0; i < 100005; i++) vis[i] = i;
    int no = 0;
    for (int i = 0; i < b; i++) {
      int x, y, z;
      cin >> x >> y >> z;
      int l = find(x), r = find(y);
      if (l == r) {
        if (val[x] - val[y] != z) no = 1;
      } else {
        vis[l] = r;
        val[l] = z + val[y] - val[x];
      }
    }
    if (no) {
      cout << "No" << '\n';
    } else {
      cout << "Yes" << '\n';
    }
  }
  return 0;
}
