Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.

There are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th route can be used to go from city v_{i} to city u_{i} (and from u_{i} to v_{i}), and it costs w_{i} coins to use this route.

Each city will be visited by "Flayer", and the cost of the concert ticket in i-th city is a_{i} coins.

You have friends in every city of Berland, and they, knowing about your programming skills, asked you to calculate the minimum possible number of coins they have to pay to visit the concert. For every city i you have to compute the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j ≠ i).

Formally, for every $i \in [ 1, n ]$ you have to calculate $\operatorname{min}_{j = 1} 2 d(i, j) + a_{j}$, where d(i, j) is the minimum number of coins you have to spend to travel from city i to city j. If there is no way to reach city j from city i, then we consider d(i, j) to be infinitely large.


-----Input-----

The first line contains two integers n and m (2 ≤ n ≤ 2·10^5, 1 ≤ m ≤ 2·10^5).

Then m lines follow, i-th contains three integers v_{i}, u_{i} and w_{i} (1 ≤ v_{i}, u_{i} ≤ n, v_{i} ≠ u_{i}, 1 ≤ w_{i} ≤ 10^12) denoting i-th train route. There are no multiple train routes connecting the same pair of cities, that is, for each (v, u) neither extra (v, u) nor (u, v) present in input.

The next line contains n integers a_1, a_2, ... a_{k} (1 ≤ a_{i} ≤ 10^12) — price to attend the concert in i-th city.


-----Output-----

Print n integers. i-th of them must be equal to the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j ≠ i).


-----Examples-----
Input
4 2
1 2 4
2 3 7
6 20 1 25

Output
6 14 1 25 

Input
3 3
1 2 1
2 3 1
1 3 1
30 10 20

Output
12 10 12

Difficulty: interview

Starter code:

Solutions:
from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(fd, stream.getvalue()) + stream.truncate(0) + stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 2*10**12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



s = sys.stdin.read().replace(b'\r',b'')
inp = []
numb = 0
 
for i in range(len(s)):
    if s[i]>=48:
        numb = 10*numb + s[i]-48
    elif s[i]!=13:
        inp.append(numb)
        numb = 0
if s[-1]>=48:
    inp.append(numb)

ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(x))
    sys.stdout.write('\n')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(fd, stream.getvalue()) + stream.truncate(0) + stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



s = sys.stdin.read().replace(b'\r',b'')
inp = []
numb = 0
 
for i in range(len(s)):
    if s[i]>=48:
        numb = 10*numb + s[i]-48
    elif s[i]!=13:
        inp.append(numb)
        numb = 0
if s[-1]>=48:
    inp.append(numb)

ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write('\n')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



s = sys.stdin.read().replace(b'\r',b'')
inp = []
numb = 0
 
for i in range(len(s)):
    if s[i]>=48:
        numb = 10*numb + s[i]-48
    elif s[i]!=13:
        inp.append(numb)
        numb = 0
if s[-1]>=48:
    inp.append(numb)

ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

###### ACTUAL CODE
s = sys.stdin.read().replace(b'\r',b'')
inp = []
numb = 0
 
for i in range(len(s)):
    if s[i]>=48:
        numb = 10*numb + s[i]-48
    elif s[i]!=13:
        inp.append(numb)
        numb = 0
if s[-1]>=48:
    inp.append(numb)

ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

import heapq
Q = [(best[i],i) for i in range(n)]
heapq.heapify(Q)

while Q:
    c,node = heapq.heappop(Q)
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            heapq.heappush(Q,(C, nei))
for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

###### REWRITTEN HEAPQ
def heappush(heap, item):
    heap.append(item)
    _siftdown(heap, len(heap)-1)

def heappop(heap):
    lastelt = heap.pop()
    if not heap:
        return lastelt

    returnitem,heap[0] = heap[0],lastelt
    _siftup(heap)
    return returnitem

# Does a pop and then a push
def heapreplace(heap, item):
    returnitem,heap[0] = heap[0],item
    _siftup(heap)
    return returnitem

# Does a push and then a pop
def heappushpop(heap, item):
    if heap and heap[0] < item:
        item, heap[0] = heap[0], item
        _siftup(heap)
    return item

def heapify(x):
    for i in reversed(range(len(x)//2)):
        _siftup(x, i)


def _siftdown(heap, pos):
    newitem = heap[pos]
    ppos = (pos-1) >> 1
    while pos and newitem < heap[ppos]:
        heap[pos] = heap[ppos]
        pos = ppos
        ppos = (pos-1) >> 1
    heap[pos] = newitem

def _siftup(heap, pos=0):
    # Move the item at pos to a leaf
    # by switching place with smallest child (bias to right)
    newitem = heap[pos]
    
    leftchild = 2*pos + 1
    rightchild = leftchild + 1
    while rightchild < len(heap):
        if heap[leftchild] < heap[rightchild]:
            heap[pos] = heap[leftchild]
            pos = leftchild
        else:
            heap[pos] = heap[rightchild]
            pos = rightchild
        leftchild = 2*pos + 1
        rightchild = leftchild + 1
    if leftchild < len(heap): # Special case of only one child
        heap[pos] = heap[leftchild]
        pos = leftchild
    # Now newitem has been moved to an leaf
    heap[pos] = newitem
    _siftdown(heap,pos)

###### ACTUAL CODE
s = sys.stdin.read().replace(b'\r',b'')
inp = []
numb = 0
 
for i in range(len(s)):
    if s[i]>=48:
        numb = 10*numb + s[i]-48
    elif s[i]!=13:
        inp.append(numb)
        numb = 0
if s[-1]>=48:
    inp.append(numb)

ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]


Q = [(best[i],i) for i in range(n)]
heapify(Q)

while Q:
    c,node = heappop(Q)
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            heappush(Q,(C, nei))
for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0; sign = 1
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            elif s[i] == b'-'[0]: sign = -1
            else: A.append(sign*numb); numb = 0; sign = 1
        if s[-1]>=b'0'[0]: A.append(sign*numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



inp = sys.stdin.readint()
ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0; sign = 1
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            elif s[i] == b'-'[0]: sign = -1
            else: A.append(sign*numb); numb = 0; sign = 1
        if s[-1] >= b'0'[0]: A.append(sign*numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



inp = sys.stdin.readint()
ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readuint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            else: A.append(numb); numb = 0
        if s and s[-1] >= b'0'[0]: A.append(numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



inp = sys.stdin.readuint()
ind = 0

n = inp[ind]
ind += 1
m = inp[ind]
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = inp[ind+0]-1
    u = inp[ind+1]-1
    w = 1.0*inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [1.0*inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readuint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            else: A.append(numb); numb = 0
        if s and s[-1] >= b'0'[0]: A.append(numb)
        return A
    def readint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0; sign = 1
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            elif s[i] == b'-'[0]: sign = -1
            else: A.append(sign*numb); numb = 0; sign = 1
        if s and s[-1] >= b'0'[0]: A.append(sign*numb)
        return A
    def readfloat(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0.0; sign = 1.0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10.0*numb + conv(s[i])-48.0
            elif s[i] == b'-'[0]: sign = -1.0
            else: A.append(sign*numb); numb = 0.0; sign = 1.0
        if s and s[-1] >= b'0'[0]: A.append(sign*numb)
        return A
    def readufloat(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0.0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10.0*numb + conv(s[i])-48.0
            else: A.append(numb); numb = 0.0
        if s and s[-1] >= b'0'[0]: A.append(numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



inp = sys.stdin.readufloat()
ind = 0

n = int(inp[ind])
ind += 1
m = int(inp[ind])
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[ind+0]-1)
    u = int(inp[ind+1]-1)
    w = inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readuint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            else: A.append(numb); numb = 0
        if s and s[-1] >= b'0'[0]: A.append(numb)
        return A
    def readint(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0; sign = 1
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10*numb + conv(s[i])-48
            elif s[i] == b'-'[0]: sign = -1
            else: A.append(sign*numb); numb = 0; sign = 1
        if s and s[-1] >= b'0'[0]: A.append(sign*numb)
        return A
    def readfloat(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0.0; sign = 1.0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10.0*numb + conv(s[i])-48.0
            elif s[i] == b'-'[0]: sign = -1.0
            else: A.append(sign*numb); numb = 0.0; sign = 1.0
        if s and s[-1] >= b'0'[0]: A.append(sign*numb)
        return A
    def readufloat(self):
        conv = ord if py2 else lambda x:x
        s = sys.stdin.read().replace(b'\r',b'')
        A = []; numb = 0.0
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10.0*numb + conv(s[i])-48.0
            else: A.append(numb); numb = 0.0
        if s and s[-1] >= b'0'[0]: A.append(numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2



inp = sys.stdin.readfloat()
ind = 0

n = int(inp[ind])
ind += 1
m = int(inp[ind])
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[ind+0]-1)
    u = int(inp[ind+1]-1)
    w = inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize:break
            c = self.stream.read(1)[0]
            curpos += 1
            if c >= b'0'[0]: numb = 10 * numb + (conv(c) - 48)
            elif c == b'-'[0]: sign = -1
            elif c != b'\r'[0]: A.append(sign*numb); numb = zero; sign = 1
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod, (Note, currently experimenting, not fully working)
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size).replace(b'\r',b'')
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize:break
            c = self.stream.read(1)[0]
            curpos += 1
            if c >= b'0'[0]: numb = 10 * numb + (conv(c) - 48)
            elif c == b'-'[0]: sign = -1
            else: A.append(sign*numb); numb = zero; sign = 1
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size).replace(b'\r',b'')
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(1000,buffsize-curpos))
            for i in range(len(s)):
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] == b'-'[0]: sign = -1
                else: A.append(sign*numb); numb = zero; sign = 1
                if len(A)==n: break
            curpos += i+1
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size).replace(b'\r',b'')
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(10000,buffsize-curpos))
            for i in range(len(s)):
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] == b'-'[0]: sign = -1
                else: A.append(sign*numb); numb = zero; sign = 1
                if len(A)==n: break
            curpos += i+1
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(10000,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(10,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(256,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(64,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(32,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, zero=0):
        conv = ord if py2 else lambda x:x
        s = self.read()
        A = []; numb = zero; sign = 1
        for i in range(len(s)):
            if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
            elif s[i] != b'\r'[0]:
                if s[i] == b'-'[0]: sign = -1
                else: A.append(sign*numb); numb = zero; sign = 1
        if s and s[-1] >= b'0'[0]: A.append(sign*numb)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

inp = sys.stdin.readnumbers(0.0)
ind = 0

n = int(inp[ind])
ind += 1
m = int(inp[ind])
ind += 1

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[ind+0]-1)
    u = int(inp[ind+1]-1)
    w = inp[ind+2]
    ind += 3
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

best = [inp[ind+i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                buffsize += len(self.read2buffer())
                if curpos==buffsize: break
            s = self.stream.read(min(64,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)<n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                buffsize += len(self.read2buffer())
                if curpos==buffsize: break
            s = self.stream.read(min(64,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)<n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        if self.stream.tell()!=curpos: self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                buffsize += len(self.read2buffer())
                if curpos==buffsize: break
            s = self.stream.read(min(128,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)<n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        if self.stream.tell()!=curpos: self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

# OLD VERSION

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                self.read2buffer()
                self.stream.seek(0,2)
                buffsize = self.stream.tell()
                self.stream.seek(curpos)
                if curpos==buffsize: break
            s = self.stream.read(min(64,buffsize-curpos))
            i = 0
            while i<len(s) and len(A)!=n:
                if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                elif s[i] != b'\r'[0]: 
                    if s[i] == b'-'[0]: sign = -1
                    else: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')

from __future__ import division, print_function
py2 = round(0.5)

if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import BytesIO, IOBase

# FastIO for PyPy2 and PyPy3 by Pajenegod,
class FastI(object):
    def __init__(self, fd=0, buffersize=2**14):
        self.stream = stream = BytesIO(); self.bufendl = 0
        def read2buffer():
            curpos = stream.tell(); s = os.read(fd, buffersize + os.fstat(fd).st_size)
            stream.seek(0,2); stream.write(s); stream.seek(curpos); return s
        self.read2buffer = read2buffer
    def read(self):
        while self.read2buffer(): pass
        return self.stream.read() if self.stream.tell() else self.stream.getvalue()
    def readline(self):
        while self.bufendl == 0: s = self.read2buffer(); self.bufendl += s.count(b'\n') + (not s)
        self.bufendl -= 1; return self.stream.readline()
    def input(self): return self.readline().rstrip(b'\r\n')
    def readnumbers(self, n,zero=0):
        conv = ord if py2 else lambda x:x
        
        A = []; numb = zero; sign = 1
        
        curpos = self.stream.tell()
        self.stream.seek(0,2)
        buffsize = self.stream.tell()
        self.stream.seek(curpos)
        
        while len(A)<n:
            if curpos>=buffsize:
                buffsize += len(self.read2buffer())
                if curpos==buffsize: break
            small_buff = min(64,buffsize-curpos)
            s = self.stream.read(small_buff)
            i = 0
            while i<small_buff and len(A)<n:
                if s[i] >= b'-'[0]:
                    if s[i] >= b'0'[0]: numb = 10 * numb + (conv(s[i]) - 48)
                    else: sign = -1    
                elif s[i] != b'\r'[0]: A.append(sign*numb); numb = zero; sign = 1
                i += 1
            curpos += i
        if curpos == buffsize and len(A)<n: A.append(sign*numb)
        assert(len(A)==n)
        if self.stream.tell()!=curpos: self.stream.seek(curpos)
        return A

class FastO(IOBase):
    def __init__(self, fd=1):
        stream = BytesIO()
        self.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
        self.write = stream.write if py2 else lambda s: stream.write(s.encode())

sys.stdin, sys.stdout = FastI(), FastO()
input = sys.stdin.readline

big = 3E12

class segheap:
    def __init__(self,data):
        n = len(data)
        m = 1
        while m<n:m*=2
        self.n = n
        self.m = m

        self.data = [big]*(2*m)
        for i in range(n):
            self.data[i+m] = data[i]
        for i in reversed(range(m)):
            self.data[i] = min(self.data[2*i],self.data[2*i+1])

    def mini(self):
        i = 1
        while i<self.m:
            if self.data[i]==self.data[2*i]:
                i = 2*i
            else:
                i = 2*i+1
        i -= self.m
        self.setter(i,big)
        return i
    def setter(self,ind,val):
        ind += self.m
        if val<self.data[ind]:
            while ind>0 and self.data[ind]>val:
                self.data[ind] = val
                ind //= 2
        elif val>self.data[ind]:
            old_val = self.data[ind]
            self.data[ind] = val
            ind //= 2
            while ind>0 and self.data[ind]==old_val:
                self.data[ind] = min(self.data[2*ind],self.data[2*ind+1])
                ind //= 2

n, m = [int(x) for x in sys.stdin.readline().split()]

inp = sys.stdin.readnumbers(3*m, 0.0)

coupl = [[] for _ in range(n)]
cost = [[] for _ in range(n)]
for _ in range(m):
    v = int(inp[_*3+0]-1)
    u = int(inp[_*3+1]-1)
    w = inp[_*3+2]
    coupl[v].append(u)
    coupl[u].append(v)
    cost[u].append(w)
    cost[v].append(w)

inp = sys.stdin.readnumbers(n, 0.0)

best = [inp[i] for i in range(n)]

Q = segheap(best)

while Q.data[1]!=big:
    c = Q.data[1]
    node = Q.mini()
    if best[node]!=c:
        continue
    for j in range(len(coupl[node])):
        nei = coupl[node][j]
        C = c+2*cost[node][j]
        if C<best[nei]:
            best[nei] = C
            Q.setter(nei,C)

for x in best:
    sys.stdout.write(str(int(x)))
    sys.stdout.write(' ')