#include <bits/stdc++.h>
using namespace std;
struct Node {
  int dis;
  Node* next;
};
Node* front = new Node();
map<int, Node*> Map;
int n, m;
int main() {
  bool ans = true;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (i == 0) {
      front->dis = 0;
      front->next = new Node();
      front->next->dis = c;
      Map[a] = front;
      Map[b] = front->next;
    } else {
      if (!Map[a] && Map[b] && ans) {
        int remoteDis = 0;
        Node* j;
        for (j = front; j != Map[b]; j = j->next) remoteDis += j->dis;
        remoteDis += j->dis;
        if (c > remoteDis) {
          Node* temp = front;
          front = new Node();
          front->next = temp;
          temp->dis = remoteDis - c;
          Map[a] = front;
        }
        if (c == remoteDis) {
          Map[a] = front;
        }
        if (c < remoteDis) {
          Node* pushin;
          for (j = front; j != Map[b]; j = j->next) {
            remoteDis -= j->dis;
            if (c >= remoteDis) {
              pushin = j;
              break;
            }
          }
          if (c > remoteDis) {
            Node* temp = new Node();
            temp->dis = remoteDis + (j->dis) - c;
            Node* newNext = pushin->next;
            pushin->next = temp;
            temp->next = newNext;
            newNext->dis = c - remoteDis;
            Map[a] = temp;
          }
          if (c == remoteDis) {
            Map[a] = pushin->next;
          }
        }
      } else if (Map[a] && !Map[b] && ans) {
        int remoteDis = 0;
        Node* j = Map[a];
        if (j->next != NULL)
          for (j = Map[a]->next; j->next != NULL; j = j->next)
            remoteDis += j->dis;
        if (c > remoteDis) {
          Node* temp = new Node();
          temp->dis = c - remoteDis;
          j->next = temp;
          Map[b] = temp;
        }
        if (c == remoteDis) {
          Map[b] = j;
        }
        if (c < remoteDis) {
          remoteDis = 0;
          Node* last = Map[a];
          for (j = Map[a]->next; j != NULL; j = j->next) {
            remoteDis += j->dis;
            if (c <= remoteDis) break;
            last = j;
          }
          if (c < remoteDis) {
            Node* temp = new Node();
            Node* newNext = last->next;
            last->next = temp;
            temp->next = newNext;
            temp->dis = c - (remoteDis - j->dis);
            newNext->dis = remoteDis - c;
            Map[b] = temp;
          }
          if (c == remoteDis) {
            Map[b] = j;
          }
        }
      } else if (Map[a] && Map[b] && ans) {
        Node* j;
        int remoteDis = 0;
        for (j = Map[a]; j != Map[b]; j = j->next)
          if (j != Map[a]) remoteDis += j->dis;
        remoteDis += j->dis;
        if (remoteDis != c) {
          ans = false;
        }
      }
    }
  }
  if (ans)
    printf("Yes");
  else
    printf("No");
  return 0;
}
