#include <bits/stdc++.h>

int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector< std::vector< int > > AB(N);
    std::map< int, int > cost;
    for(int i=0; i<M; i++){
        int a, b, c;
        std::cin >> a >> b >> c;
        a--;
        b--;
        int ab = a * N + b;
        auto itr = cost.find(ab);
        if(itr == cost.end()){
            AB[a].push_back(b);
            cost[ab] = c;
        }else if(c < itr->second){
            cost[ab] = c;
        }
    }
    
    for(int i=0; i<N; i++){
        std::priority_queue< std::pair< int, int >, std::vector<std::pair< int, int >>, std::greater<std::pair< int, int >> > time_pos;
        
        std::pair< int, int > tmp;
        tmp.first = 0;
        tmp.second = i;
        time_pos.push(tmp);
        std::vector< int > min(N, 1e9);
        
        while(!time_pos.empty()){
            tmp = time_pos.top(); time_pos.pop();
            int c_pos = tmp.second;
            int c_time = tmp.first;
            
            if(c_time >= min[c_pos]){
                continue;
            }
            
            if(c_time != 0){
                min[c_pos] = c_time;
            }
            
            for(int j=0; j<AB[c_pos].size(); j++){
                tmp.second = AB[c_pos][j];
                tmp.first = c_time + cost[c_pos * N + AB[c_pos][j]];
                if(tmp.first >= min[AB[c_pos][j]]){
                    continue;
                }
                time_pos.push(tmp);
            }
        }
        
        if(min[i] != 1e9){
            std::cout << min[i] << std::endl;
        }else{
            std::cout << -1 << std::endl;
        }
        
    }
    
    return 0;
}


#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
    LL n,m,t,flag=1,last=0,cap;
    cin>>n>>m>>t;
    cap=n;
    while(m--){
        LL arrive,stay;
        cin>>arrive>>stay;
        LL dis=arrive-last;
        n-=dis;
        if(n<=0){
            flag=0;
        }
        n+=stay-arrive;
        n=min(n,cap);
        last=stay;
    }
    LL dis=t-last;
    n-=dis;
    if(n<=0){
        flag=0;
    }
    if (flag){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }


    return 0;
}
