For this Question: There are n cities in the universe and our beloved Spider-Man is in city 1. He doesn't like to travel by vehicles, so he shot webs forming edges between some pairs of cities. Eventually, there were m edges and each had some cost associated with it.

Spider-Man now defines the cost of a path p from cities p<sub>1</sub> to p<sub>k</sub> as w<sub>1</sub> + 2w<sub>2</sub> + 3w<sub>3</sub> . . . + (k-1)*w<sub>k-1</sub>, where w<sub>i</sub> is the cost of an edge from p<sub>i</sub> to p<sub>i+1</sub>. 
Thus, the minimum distance between cities i and j is the smallest cost of a path starting from i and ending at j.

Find the minimum distance from city 1 to all the cities i (1 ≤ i ≤ n). If there exists no way to go from city 1 to city i, print -1.

<b>Note: </b>
All the edges are bidirectional. There may be multiple edges and self-loops in the input.The first line contains two space separated integers n and m - the number of nodes and edges respectively.
The next m lines contain three-space separated integers x, y, w - representing an edge between x and y with cost w.

<b>Constraints:</b>
1 ≤ n ≤ 3000
0 ≤ m ≤ 10000
1 ≤ x, y ≤ n
1 ≤ w ≤ 10<sup>9</sup>Output n lines. In the i<sup>th</sup> line, output the minimum distance from city 1 to the i<sup>th</sup> city. If there exists no such path, output -1.Sample Input
6 5
2 4 3
2 3 4
2 1 2
2 5 6
1 5 2

Sample Output
0
2
10
8
2
-1

Explanation:
Shortest path from 1 to 3 is (1->2->3)  with total weight= 1*2+2*4=10
Shortest path from 1 to 5 is (1->5)  with total weight= 1*2=2
There doesn't exist any path from 1 to 6 so print -1
, I have written this Solution Code: import java.io.*;import java.util.*;import java.math.*;import static java.lang.Math.*;import static java.
        util.Map.*;import static java.util.Arrays.*;import static java.util.Collections.*;
import static java.lang.System.*;
public class Main
{

    public void tq()throws Exception
    {
        st=new StringTokenizer(bq.readLine());
        int tq=1;
        sb=new StringBuilder(2000000);
        o:
        while(tq-->0)
        {
            int n=i();
            int m=i();
            LinkedList<int[]> l[]=new LinkedList[n];
            for(int x=0;x<n;x++)l[x]=new LinkedList<>();
            for(int x=0;x<m;x++)
            {
                int a=i()-1;
                int b=i()-1;
                int c=i();
                l[a].add(new int[]{b,c});
                l[b].add(new int[]{a,c});
            }
            long d[]=new long[n];
            for(int x=0;x<n;x++)d[x]=maxl;
            d[0]=0l;
            PriorityQueue<long[]> p=new PriorityQueue<>(5000,(a,b)->a[2]-b[2]<1l?-1:1);
            p.add(new long[]{0l,0,0});
            while(p.size()>0)
            {
                long r[]=p.poll();
                long di=r[0];
                int no=(int)r[1];
                long mu=r[2];

                for(int e[]:l[no])
                {
                    int node=e[0];
                    int w=e[1];
                    long de=di+w*(mu+1);
                    if(d[node]>de)
                    {
                        d[node]=de;
                        p.add(new long[]{de,node,mu+1});
                    }
                }
            }
            for(long x:d)
            {
                sl(x==maxl?-1:x);
            }
        }
        p(sb);
    }
    int di[][]={{-1,0},{1,0},{0,-1},{0,1}};
    int de[][]={{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{-1,1},{1,-1}};
    long mod=1000000007l;int max=Integer.MAX_VALUE,min=Integer.MIN_VALUE;long maxl=Long.MAX_VALUE, minl=Long.
        MIN_VALUE;BufferedReader bq=new BufferedReader(new InputStreamReader(in));StringTokenizer st;
    StringBuilder sb;public static void main(String[] a)throws Exception{new Main().tq();}int[] so(int ar[])
{Integer r[]=new Integer[ar.length];for(int x=0;x<ar.length;x++)r[x]=ar[x];sort(r);for(int x=0;x<ar.length;
                                                                                       x++)ar[x]=r[x];return ar;}long[] so(long ar[]){Long r[]=new Long[ar.length];for(int x=0;x<ar.length;x++)
    r[x]=ar[x];sort(r);for(int x=0;x<ar.length;x++)ar[x]=r[x];return ar;}
    char[] so(char ar[]) {Character
            r[]=new Character[ar.length];for(int x=0;x<ar.length;x++)r[x]=ar[x];sort(r);for(int x=0;x<ar.length;x++)
        ar[x]=r[x];return ar;}void s(String s){sb.append(s);}void s(int s){sb.append(s);}void s(long s){sb.
        append(s);}void s(char s){sb.append(s);}void s(double s){sb.append(s);}void ss(){sb.append(' ');}void sl
        (String s){sb.append(s);sb.append("\n");}void sl(int s){sb.append(s);sb.append("\n");}void sl(long s){sb
        .append(s);sb.append("\n");}void sl(char s) {sb.append(s);sb.append("\n");}void sl(double s){sb.append(s)
;sb.append("\n");}void sl(){sb.append("\n");}int l(int v){return 31-Integer.numberOfLeadingZeros(v);}
    long l(long v){return 63-Long.numberOfLeadingZeros(v);}int sq(int a){return (int)sqrt(a);}long sq(long a)
{return (long)sqrt(a);}long gcd(long a,long b){while(b>0l){long c=a%b;a=b;b=c;}return a;}int gcd(int a,int b)
{while(b>0){int c=a%b;a=b;b=c;}return a;}boolean pa(String s,int i,int j){while(i<j)if(s.charAt(i++)!=
        s.charAt(j--))return false;return true;}boolean[] si(int n) {boolean bo[]=new boolean[n+1];bo[0]=true;bo[1]
        =true;for(int x=4;x<=n;x+=2)bo[x]=true;for(int x=3;x*x<=n;x+=2){if(!bo[x]){int vv=(x<<1);for(int y=x*x;y<=n;
                                                                                                     y+=vv)bo[y]=true;}}return bo;}long mul(long a,long b,long m) {long r=1l;a%=m;while(b>0){if((b&1)==1)
    r=(r*a)%m;b>>=1;a=(a*a)%m;}return r;}int i()throws IOException{if(!st.hasMoreTokens())st=new
        StringTokenizer(bq.readLine());return Integer.parseInt(st.nextToken());}long l()throws IOException
{if(!st.hasMoreTokens())st=new StringTokenizer(bq.readLine());return Long.parseLong(st.nextToken());}String
s()throws IOException {if (!st.hasMoreTokens())st=new StringTokenizer(bq.readLine());return st.nextToken();}
    double d()throws IOException{if(!st.hasMoreTokens())st=new StringTokenizer(bq.readLine());return Double.
            parseDouble(st.nextToken());}void p(Object p){out.print(p);}void p(String p){out.print(p);}void p(int p)
{out.print(p);}void p(double p){out.print(p);}void p(long p){out.print(p);}void p(char p){out.print(p);}void
p(boolean p){out.print(p);}void pl(Object p){out.println(p);}void pl(String p){out.println(p);}void pl(int p)
{out.println(p);}void pl(char p){out.println(p);}void pl(double p){out.println(p);}void pl(long p){out.
        println(p);}void pl(boolean p)
{out.println(p);}void pl(){out.println();}void s(int a[]){for(int e:a)
{sb.append(e);sb.append(' ');}sb.append("\n");}
    void s(long a[])
    {for(long e:a){sb.append(e);sb.append(' ')
    ;}sb.append("\n");}void s(int ar[][]){for(int a[]:ar){for(int e:a){sb.append(e);sb.append(' ');}sb.append
        ("\n");}}
    void s(char a[])
    {for(char e:a){sb.append(e);sb.append(' ');}sb.append("\n");}void s(char ar[][])
{for(char a[]:ar){for(char e:a){sb.append(e);sb.append(' ');}sb.append("\n");}}int[] ari(int n)throws
        IOException {int ar[]=new int[n];if(!st.hasMoreTokens())st=new StringTokenizer(bq.readLine());for(int x=0;
                                                                                                          x<n;x++)ar[x]=Integer.parseInt(st.nextToken());return ar;}int[][] ari(int n,int m)throws
        IOException {int ar[][]=new int[n][m];for(int x=0;x<n;x++){if (!st.hasMoreTokens())st=new StringTokenizer
        (bq.readLine());for(int y=0;y<m;y++)ar[x][y]=Integer.parseInt(st.nextToken());}return ar;}long[] arl
        (int n)throws IOException {long ar[]=new long[n];if(!st.hasMoreTokens()) st=new StringTokenizer(bq.readLine())
        ;for(int x=0;x<n;x++)ar[x]=Long.parseLong(st.nextToken());return ar;}long[][] arl(int n,int m)throws
        IOException {long ar[][]=new long[n][m];for(int x=0;x<n;x++) {if(!st.hasMoreTokens()) st=new
        StringTokenizer(bq.readLine());for(int y=0;y<m;y++)ar[x][y]=Long.parseLong(st.nextToken());}return ar;}
    String[] ars(int n)throws IOException {String ar[] =new String[n];if(!st.hasMoreTokens())st=new
            StringTokenizer(bq.readLine());for(int x=0;x<n;x++)ar[x]=st.nextToken();return ar;}double[] ard
        (int n)throws IOException {double ar[] =new double[n];if(!st.hasMoreTokens())st=new StringTokenizer
        (bq.readLine());for(int x=0;x<n;x++)ar[x]=Double.parseDouble(st.nextToken());return ar;}double[][] ard
        (int n,int m)throws IOException{double ar[][]=new double[n][m];for(int x=0;x<n;x++) {if(!st.hasMoreTokens())
    st=new StringTokenizer(bq.readLine());for(int y=0;y<m;y++) ar[x][y]=Double.parseDouble(st.nextToken());}
    return ar;}char[] arc(int n)throws IOException{char ar[]=new char[n];if(!st.hasMoreTokens())st=new
        StringTokenizer(bq.readLine());for(int x=0;x<n;x++)ar[x]=st.nextToken().charAt(0);return ar;}char[][]
arc(int n,int m)throws IOException {char ar[][]=new char[n][m];for(int x=0;x<n;x++){String s=bq.readLine();
    for(int y=0;y<m;y++)ar[x][y]=s.charAt(y);}return ar;}void p(int ar[])
{StringBuilder sb=new StringBuilder
        (2*ar.length);for(int a:ar){sb.append(a);sb.append(' ');}out.println(sb);}void p(int ar[][])
{StringBuilder sb=new StringBuilder(2*ar.length*ar[0].length);for(int a[]:ar){for(int aa:a){sb.append(aa);
    sb.append(' ');}sb.append("\n");}p(sb);}void p(long ar[]){StringBuilder sb=new StringBuilder
        (2*ar.length);for(long a:ar){ sb.append(a);sb.append(' ');}out.println(sb);}
    void p(long ar[][])
    {StringBuilder sb=new StringBuilder(2*ar.length*ar[0].length);for(long a[]:ar){for(long aa:a){sb.append(aa);
        sb.append(' ');}sb.append("\n");}p(sb);}void p(String ar[]){int c=0;for(String s:ar)c+=s.length()+1;
    StringBuilder sb=new StringBuilder(c);for(String a:ar){sb.append(a);sb.append(' ');}out.println(sb);}
    void p(double ar[])
    {StringBuilder sb=new StringBuilder(2*ar.length);for(double a:ar){sb.append(a);
        sb.append(' ');}out.println(sb);}void p
        (double ar[][]){StringBuilder sb=new StringBuilder(2*
        ar.length*ar[0].length);for(double a[]:ar){for(double aa:a){sb.append(aa);sb.append(' ');}sb.append("\n")
;}p(sb);}void p(char ar[])
{StringBuilder sb=new StringBuilder(2*ar.length);for(char aa:ar){sb.append(aa);
    sb.append(' ');}out.println(sb);}void p(char ar[][]){StringBuilder sb=new StringBuilder(2*ar.length*ar[0]
        .length);for(char a[]:ar){for(char aa:a){sb.append(aa);sb.append(' ');}sb.append("\n");}p(sb);}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?