#include <bits/stdc++.h>
using namespace std;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
const double pi = acos(-1);
const int oo = 0x3f3f3f3f;
template <class T>
inline T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
int cmp(double x, double y = 0, double tol = 1e-9) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
const int MAX_N = 123456;
int arr[MAX_N];
map<pair<int, int>, int> M;
int main() {
  int N, m, x, y, d;
  memset(arr, 0, sizeof(arr));
  scanf("%d %d", &N, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &x, &y, &d);
    M[pair<int, int>(x, y)] = d;
  }
  map<pair<int, int>, int>::iterator it;
  bool ans = true;
  for (it = M.begin(); it != M.end(); it++) {
    x = (it->first).first;
    y = (it->first).second;
    d = it->second;
    if (M.find(pair<int, int>(y, x)) != M.end() &&
        M[pair<int, int>(y, x)] + d != 0)
      ans = false;
    if (arr[x] == 0 || arr[y] == 0) {
      arr[y] = arr[x] + d;
    } else if (arr[y] - arr[x] != d)
      ans = false;
  }
  if (ans)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
