#include <bits/stdc++.h>
using namespace std;


using pii = pair<long long,int>;

void mincammino(int N, int M, vector<int> X, vector<int> Y, vector<int> P, vector<long long>& D){
    vector<vector<pii>> adj(N);
    for(int i=0; i<M; i++){
        adj[X[i]].push_back({P[i],Y[i]});
    }
    for(int i=0; i<N; i++){
        D[i]=10e17;
    }
    D[0]=0;
    priority_queue<pii, vector<pii>> q;
    q.push({0,0});
    while(!q.empty()){
        int nodo=q.top().second;
        long long dist=q.top().first;
        q.pop();
        for(auto to : adj[nodo]){
            long long newDist = dist+to.first;
            if(D[to.second]>newDist){
                D[to.second]=newDist;
                q.push({newDist,to.second});
            }
        }
    }
    for(int i=0; i<N; i++){
        if(D[i]==10e17){
            D[i]=-1;
        }
    }
}
