#include <bits/stdc++.h>
using namespace std;
int P[100002] = {0};
bool visited[100002] = {false};
bool check(int l, int r, int temp) {
  if (visited[l] == false && visited[r] == false) {
    P[l] = 0;
    P[r] = temp;
    visited[l] = true;
    visited[r] = true;
  } else if (visited[l] == false) {
    P[l] = P[r] - temp;
    visited[l] = true;
  } else if (visited[r] == false) {
    P[r] = P[l] + temp;
    visited[r] = true;
  }
  return P[r] - P[l] == temp;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  bool end = false;
  for (int i = 0; i < (m); i++) {
    int l, r, temp;
    scanf("%d%d%d", &l, &r, &temp);
    if (!end && !check(l, r, temp)) {
      end = true;
    }
  }
  end ? cout << "No\n" : cout << "Yes\n";
  return 0;
}
