#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
struct Matrix {
  vector<vector<int>> data;
  int r, c;
  Matrix(int row, int col, bool identity = false) : r(row), c(col) {
    data.assign(row, vector<int>(col, 0));
    if (identity) {
      for (int i = 0; i < r; ++i) {
        data[i][i] = 1;
      }
    }
  }
  Matrix operator*(Matrix &other) {
    int m = r, n = c, p = other.c;
    Matrix res(m, p);
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < p; ++j) {
        for (int k = 0; k < n; ++k) {
          res.data[i][j] += data[i][k] * other.data[k][j];
        }
      }
    }
    return res;
  }
};
vector<int> extendGcd(int a, int b) {
  if (b == 0) {
    return {a, 1, 0};
  } else {
    vector<int> tmp = extendGcd(b, a % b);
    return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
  }
}
Matrix matrix_power(Matrix base, long long exp) {
  int n = base.r;
  Matrix res(n, n, true);
  while (exp) {
    if (exp & 1) {
      res = res * base;
    }
    base = base * base;
    exp >>= 1;
  }
  return res;
}
template <typename T>
T power_mod(T base, int exp, int mod = 1000000007) {
  T res = 1;
  while (exp) {
    if (exp & 1) res = res * base % mod;
    base = base * base % mod;
    exp >>= 1;
  }
  return res;
}
template <typename T>
T power(T base, int exp) {
  T res = 1;
  while (exp) {
    if (exp & 1) res *= base;
    base *= base;
    exp >>= 1;
  }
  return res;
}
long long inv(long long a) { return power_mod(a, 1000000007 - 2); }
int n, m;
vector<pair<int, int>> e[100010];
bool visited[100010];
int pos[100010];
int pa[100010];
int Find(int x) {
  if (x != pa[x]) {
    pa[x] = Find(pa[x]);
  }
  return pa[x];
}
bool Union(int a, int b) {
  int ra = Find(a), rb = Find(b);
  if (ra != rb) {
    pa[ra] = rb;
    return true;
  }
  return false;
}
unordered_set<int> record;
bool dfs(int cur, int from) {
  visited[cur] = true;
  for (pair<int, int> next : e[cur]) {
    if (next.first == from) continue;
    if (visited[next.first]) {
      if (pos[next.first] != pos[cur] + next.second) {
        return false;
      }
    } else {
      pos[next.first] = pos[cur] + next.second;
      if (!dfs(next.first, cur)) return false;
    }
  }
  return true;
}
bool solveGroup(int rt) {
  if (!dfs(rt, 0)) return false;
  int lower = INT_MAX, upper = INT_MIN;
  for (int i = 1; i <= n; ++i) {
    if (Find(i) == rt) {
      lower = min(lower, pos[i]);
      upper = max(upper, pos[i]);
    }
  }
  if (upper - lower > (int)1e9) return false;
  return true;
}
int main() {
  cin >> n >> m;
  int l, r, d;
  for (int i = 1; i <= n; ++i) {
    pa[i] = i;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &l, &r, &d);
    e[l].push_back({r, d});
    e[r].push_back({l, -d});
    Union(l, r);
  }
  for (int i = 1; i <= n; ++i) {
    int rt = Find(i);
    if (record.find(rt) != record.end()) continue;
    record.insert(rt);
    bool flag = solveGroup(rt);
    if (!flag) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
