#include <bits/stdc++.h>
typedef struct {
  std::set<int> st;
  int arr[100000];
} Tree;
bool find(int n, Tree t) {
  if (t.st.count(n) == 0)
    return false;
  else
    return true;
}
bool merge(Tree& t0, Tree t1) {
  bool found = false;
  int id;
  for (auto x : t0.st) {
    if (find(x, t1)) {
      id = x;
      found = true;
      break;
    }
  }
  if (!found) return true;
  int diff = t0.arr[id] - t1.arr[id];
  for (auto x : t1.st) {
    if (find(x, t0)) {
      if (t0.arr[x] != t1.arr[x] + diff) return false;
    } else {
      t0.st.insert(x);
      t0.arr[x] = t1.arr[x] + diff;
    }
  }
  return true;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  std::vector<Tree> root;
  while (m--) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    l--;
    r--;
    bool bl = false, br = false;
    for (auto& x : root) {
      bl = find(l, x);
      br = find(r, x);
      if (bl || br) {
        if (bl && br) {
          if ((x.arr[r] - x.arr[l]) != d) {
            printf("No\n");
            return 0;
          }
        } else if (bl) {
          x.st.insert(r);
          x.arr[r] = x.arr[l] + d;
        } else if (br) {
          x.st.insert(l);
          x.arr[l] = x.arr[r] - d;
        }
        break;
      }
    }
    if (!(bl || br)) {
      Tree temp;
      temp.st.insert(l);
      temp.st.insert(r);
      temp.arr[l] = 0;
      temp.arr[r] = d;
      root.push_back(temp);
    }
  }
  printf("Yes\n");
  return 0;
}
