#include<bits/stdc++.h>
using namespace std;
//#include<atcoder/all>
//using namespace atcoder;
using ll = long long;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a) (a).begin(),(a).end()
using P = pair<int, int>;
void Main(){
    int n, m;
    cin >> n >> m;
    vector<vector<P>> path(n);
    For(i,0,m){
        int a, b, c;
        cin >> a >> b >> c;
        path[a-1].push_back({b-1, c});
    }
    auto dijkstra = [&](int start, auto &graph){
        vector<int> dist(n+1, 1e9);
        priority_queue<P, vector<P>, greater<P>> pq;
        pq.push({0, start});
        while(!pq.empty()){
            auto [cur, now] = pq.top();
            pq.pop();
            if(cur > dist[now]) continue;
            for(auto [to, cost]:graph[now]){
                if(dist[to] > cur + cost){
                    dist[to] = cur + cost;
                    pq.push({dist[to], to});
                }
            }
        }
        return dist[start] < 1e9 ? dist[start] : -1;
    };
    For(i,0,n) cout << dijkstra(i, path) << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
unsigned long long r,x,y;
int main(){
    cin >> r >> x >> y;
    unsigned long long target = x*x+y*y;
    unsigned long long r2 = r*r;
    unsigned long long ans = 0;
    if(target%r2==0){
        ans = target/r2;
        if(sqrt(ans)!=(unsigned long long)sqrt(ans)){
            cout << (unsigned long long)sqrt(ans)+1 << endl;
        }else{
            cout << (unsigned long long)sqrt(ans) << endl;
        }
    }else if(r2>target){
        cout << 2 << endl;
    }else{
        long double tmp = (long double)target/(long double)r2;
        if(sqrt(tmp)!=(long)sqrt(tmp)){
            cout << (long)sqrt(tmp)+1 << endl;
        }else{
            cout << (long)sqrt(tmp) << endl;
        }
    }
    return 0;
}