#include using namespace std; typedef long long ll; typedef vector vl; typedef pair pl; typedef priority_queue pq; typedef priority_queue> pqr; struct edge { ll from; ll to; ll cost; edge(ll f, ll t, ll c) : from(f), to(t), cost(c) { } }; typedef vector > Graph; typedef vector > WGraph; #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define rep3(i, k, n) for(int i = k; i < (int)(n); i++) #define all(v) v.begin(), v.end() #define pb emplace_back #define V vector #define SZ(x) (x).size() #define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl #define uniquify(vec) (vec).erase(std::unique((vec).begin(), (vec).end()), (vec).end()) constexpr ll MOD1 = 1e9 + 7; constexpr ll MOD9 = 998244353; constexpr ll INF = MOD1*MOD1+1; ll dnum(ll d){ return to_string(d).length(); } ll power(ll x, ll n){ ll ret=1; while(n>0){ if(n&1) ret = ret * x; x = x*x; n >>= 1; } return ret; } template void rsort(V &v){ sort(all(v), greater()); } template std::ostream &operator<<(std::ostream& os, const pair &p){ os << "(" << p.first << ", " << p.second << ")"; return os; } template std::ostream &operator<<(std::ostream& os, const vector &v){ int n = v.size(); os << "["; for(int i = 0; i < n; i++){ if(i == n - 1) os << v[i]; else os << v[i] << ", "; } os << "]"; return os; } template std::ostream &operator<<(std::ostream& os, const map &mp){ for(auto iter = mp.begin(); iter != mp.end(); iter++){ os << "(" << iter->first << ", " << iter->second << ")" << " "; } return os; } template std::ostream &operator<<(std::ostream& os, const set &s){ os << "{"; for(auto c : s) os << c << " "; os << "}"; return os; } template bool chmax(T &a, const T& b) { if (a < b) {a = b; return true;} return false; } template bool chmin(T &a, const T& b) { if (a > b) {a = b; return true;} return false; } template void fin(const T &a){ cout << a << '\n'; exit(0); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll n,m; cin >> n >> m; V> list(n); rep(i,m){ ll i1, i2, s; cin >> i1 >> i2 >> s; list[i2].pb(i1, s); } vl dp(1<