#include <bits/stdc++.h>
using namespace std;
int people[200000] = {};
int visited[200000] = {};
vector<pair<int, int>> rights[200000];
vector<pair<int, int>> lefts[200000];
int main() {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    if (c == 0) {
      cout << "No" << endl;
      return 0;
    }
    rights[a].push_back(make_pair(b, c));
    lefts[b].push_back(make_pair(a, c));
  }
  for (int i = 1; i <= n; ++i) {
    if (visited[i] == 0) {
      queue<int> now;
      map<int, int> kaburi;
      kaburi[0] = 1;
      visited[i] = 1;
      now.push(i);
      while (now.empty() == false) {
        int ho = now.front();
        now.pop();
        for (int q = 0; q < rights[ho].size(); ++q) {
          if (visited[rights[ho][q].first] == true) {
            if (people[rights[ho][q].first] - people[ho] !=
                rights[ho][q].second) {
              cout << "No" << endl;
              return 0;
            }
          } else {
            people[rights[ho][q].first] = people[ho] + rights[ho][q].second;
            if (kaburi[people[rights[ho][q].first]] == 1) {
              cout << "No" << endl;
              return 0;
            }
            kaburi[people[rights[ho][q].first]] = 1;
            visited[rights[ho][q].first] = 1;
            now.push(rights[ho][q].first);
          }
        }
        for (int q = 0; q < lefts[ho].size(); ++q) {
          if (visited[lefts[ho][q].first] == true) {
            if (people[lefts[ho][q].first] - people[ho] !=
                -lefts[ho][q].second) {
              cout << "No" << endl;
              return 0;
            }
          } else {
            people[lefts[ho][q].first] = people[ho] - lefts[ho][q].second;
            if (kaburi[people[lefts[ho][q].first]] == 1) {
              cout << "No" << endl;
              return 0;
            }
            kaburi[people[lefts[ho][q].first]] = 1;
            visited[lefts[ho][q].first] = 1;
            now.push(lefts[ho][q].first);
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
