#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) {}
};
vector<int> node[100005] = {};
int vis[100005] = {};
int flag = 0;
map<int, int> dis[100005];
void re(int now, int g, int d, int l) {
  if (vis[now]) return;
  if (d > l) return;
  if (d != l && now == g) flag = 1;
  vis[now] = 1;
  for (int i = 0; i < node[now].size(); i++) {
    int k = node[now][i];
    re(k, g, d + dis[now][k], l);
  }
}
void check(int now, int g) {
  if (vis[now]) {
    return;
  }
  if (now == g) {
    flag = 1;
    return;
  }
  vis[now] = 1;
  for (int i = 0; i < node[now].size(); i++) {
    int k = node[now][i];
    check(k, g);
  }
}
int main() {
  int a, b;
  while (cin >> a >> b) {
    int no = 0;
    for (int i = 0; i < b; i++) {
      memset((vis), (0), sizeof(vis));
      flag = 0;
      int x, y, z;
      cin >> x >> y >> z;
      re(x, y, 0, z);
      memset((vis), (0), sizeof(vis));
      check(y, x);
      if (!flag) {
        dis[x][y] = z;
        node[x].push_back(y);
      } else {
        no = 1;
      }
    }
    if (no) {
      cout << "No" << '\n';
    } else {
      cout << "Yes" << '\n';
    }
  }
  return 0;
}
