#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b, c;
long long T[100010];
bool vis[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    if (vis[a] == 0 && vis[b] == 0) {
      T[a] = 0, T[b] = c;
    } else if (vis[b] == 0) {
      T[b] = T[a] + c;
    } else if (vis[a] == 0) {
      T[a] = T[b] - c;
    } else {
      if (T[b] - T[a] != c) {
        printf("No");
        return 0;
      }
    }
    vis[a] = vis[b] = 1;
  }
  printf("Yes");
}
