#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100005;
int N, M, L, R, D;
vector<pair<int, int> > adj[SIZE];
bool visited[SIZE];
long long int pos[SIZE];
bool isEnd;
void search(int here) {
  visited[here] = true;
  for (int i = 0; i < adj[here].size(); ++i) {
    int next = adj[here][i].first;
    int dist = adj[here][i].second;
    if (visited[next]) {
      if (pos[next] != pos[here] + dist) {
        isEnd = true;
      }
    } else {
      pos[next] = pos[here] + dist;
      search(next);
    }
  }
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &L, &R, &D);
    adj[L].push_back({R, D});
    adj[R].push_back({L, -D});
  }
  search(L);
  if (isEnd)
    printf("No\n");
  else
    printf("Yes\n");
}
