Dijkstra Problem

My code seems to make complete sense, I don’t see why my submission is not getting accepted. Kindly guide me on the same.
The sample test case is also passed successfully.

Thank You.

For unreachable nodes, print -1.
Consider a testcase like
1
4 2
1 2 24
1 4 20
1

The expected output is
24 -1 20

However you code prints null in place of -1.

Thank you, now that I have included the case for avoiding null and printing -1 if node is unreachable, it still shows Wrong Answer. Kindly assist. Thank you.

try for this input :
1
20 54
1 7 45
2 14 15
3 7 29
4 1 48
5 1 66
6 7 17
7 14 15
8 14 43
9 1 27
10 1 33
11 14 64
12 14 27
13 7 66
14 7 54
15 14 56
16 7 21
17 1 20
18 1 34
19 7 52
20 14 14
9 14 9
15 1 39
12 1 24
9 1 16
1 2 33
18 1 46
9 1 28
15 14 3
12 1 27
1 2 5
15 1 34
1 2 28
9 7 16
3 7 23
9 7 21
9 14 19
3 1 20
3 1 5
12 14 19
3 14 2
12 1 46
3 14 5
9 14 44
6 14 26
9 14 16
9 14 34
6 7 42
3 14 27
1 7 9
1 7 41
15 14 19
12 7 13
3 7 10
1 7 2
17
correct output : 20 25 25 68 86 39 22 70
you get: 20 53 40 68 86 68 57 85 47 53 106 44 123 42 59 78 54 109 56