#include <bits/stdc++.h>
using namespace std;
const int INF = 20050226;
int dist[20000];
vector<pair<int, int> > edg[20000];
bool ok = false;
bool vis[20000];
vector<int> mention;
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = true;
  for (int i = 0; i < edg[x].size(); i++) {
    int a = edg[x][i].first;
    int b = edg[x][i].second;
    if (dist[a] != -1 and dist[x] + b != dist[a]) {
      ok = false;
    }
    dist[a] = dist[x] + b;
    dfs(a);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y, d;
    cin >> x >> y >> d;
    edg[x].push_back(make_pair(y, d));
    edg[y].push_back(make_pair(x, -d));
    mention.push_back(x);
    mention.push_back(y);
  }
  for (int i = 0; i < mention.size(); i++) {
    ok = true;
    memset(dist, -1, sizeof(dist));
    memset(vis, 0, sizeof(vis));
    dist[mention[i]] = 0;
    dfs(mention[i]);
    if (ok == true) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}
