#include <bits/stdc++.h>
using namespace std;
struct Person {
  long long x;
  int component;
  bool seen;
};
const int MAX_PERSONS = 100010;
Person persons[MAX_PERSONS];
void solve() {
  vector<vector<int>> connected_components;
  int N, M;
  cin >> N;
  cin >> M;
  for (int i = 0; i < N; ++i) {
    persons[i] = {-1, -1, false};
  }
  for (int i = 0; i < M; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    if (!persons[l].seen && !persons[r].seen) {
      persons[l].x = 0;
      persons[r].x = d;
      persons[l].component = connected_components.size();
      persons[r].component = connected_components.size();
      connected_components.push_back({l, r});
    } else if (!persons[l].seen) {
      persons[l].component = persons[r].component;
      persons[l].x = persons[r].x - d;
      connected_components[persons[r].component].push_back(l);
    } else if (!persons[r].seen) {
      persons[r].component = persons[l].component;
      persons[r].x = persons[l].x + d;
      connected_components[persons[l].component].push_back(r);
    } else {
      if (persons[l].component == persons[r].component) {
        if (persons[l].x + d != persons[r].x) {
          cout << "No" << endl;
          return;
        }
      } else {
        vector<int> left_component = connected_components[persons[l].component];
        vector<int> right_component =
            connected_components[persons[r].component];
        if (left_component.size() > right_component.size()) {
          for (int j = 0; j < right_component.size(); ++j) {
            persons[right_component[j]].x =
                persons[right_component[j]].x + persons[l].x + d;
            persons[right_component[j]].component = persons[l].component;
            connected_components[persons[l].component].push_back(
                right_component[j]);
          }
          connected_components[persons[r].component].clear();
        } else {
          for (int j = 0; j < left_component.size(); ++j) {
            persons[left_component[j]].x =
                persons[left_component[j]].x + persons[r].x - d;
            persons[left_component[j]].component = persons[r].component;
            connected_components[persons[r].component].push_back(
                left_component[j]);
          }
          connected_components[persons[l].component].clear();
        }
      }
    }
    persons[l].seen = true;
    persons[r].seen = true;
  }
  for (int i = 0; i < connected_components.size(); ++i) {
    vector<int> component = connected_components[i];
    if (component.size() > 0) {
      long long mx = LONG_MIN;
      long long mn = LONG_MAX;
      for (int j = 0; j < component.size(); ++j) {
        if (persons[component[j]].x < mn) {
          mn = persons[component[j]].x;
        } else if (persons[component[j]].x > mx) {
          mx = persons[component[j]].x;
        }
      }
      if (mx - mn > 1e9) {
        cout << "No" << endl;
        return;
      }
    }
  }
  cout << "Yes" << endl;
}
int main() { solve(); }
