#include <bits/stdc++.h>
#pragma GCC optimize("O3")
namespace opl {
namespace random {
class Random {
  using engine_t = std::mt19937;
  engine_t engine;

 public:
  Random(bool no_random = true) : engine(no_random ? 0 : (int)(time(0))) {}
  int getInt() { return engine(); }
  double getDouble() { return getInt() * 1.0 / engine_t::max(); }
};
static Random rand(0 != 0 ? true : false);
}  // namespace random
using random::rand;
using random::Random;
}  // namespace opl
namespace opl {
namespace comparator {
enum class Result { LESS = -1, EQUAL = 0, GREATER = 1 };
struct SupportsSpaceshipTag {};
template <typename T, typename Less = std::less<T>>
struct SpaceshipComparator {
  Less less;
  Result operator()(const T& lhs, const T& rhs) const {
    if (less(lhs, rhs)) {
      return Result::LESS;
    }
    if (less(rhs, lhs)) {
      return Result::GREATER;
    }
    return Result::EQUAL;
  }
  int compare(const T& lhs, const T& rhs) const {
    auto r = (*this)(lhs, rhs);
    if (r == Result::LESS) return -1;
    if (r == Result::EQUAL) return 0;
    if (r == Result::GREATER) return 1;
  }
};
}  // namespace comparator
}  // namespace opl
namespace opl {
namespace treap {
template <typename Key, typename Prior = int>
struct node {
  using key_t = Key;
  using priority_t = Prior;
  key_t key;
  priority_t priority;
  node *left, *right;
  virtual void push() {}
  virtual void relax() {}
  node(key_t _key) {
    key = _key;
    priority = opl::rand.getInt();
    left = right = nullptr;
  }
};
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
std::pair<N*, N*> split(N* v, const typename N::key_t& x, bool split_eq_to_left,
                        Comp comp) {
  N* l;
  N* r;
  if (!v) {
    l = r = nullptr;
    return std::make_pair(l, r);
  }
  v->push();
  comparator::Result res = comp(v->key, x);
  bool split_cur_to_left = res == comparator::Result::LESS;
  if (res == comparator::Result::EQUAL && split_eq_to_left)
    split_cur_to_left = true;
  if (!split_cur_to_left) {
    std::tie(l, v->left) = split<N>((N*)v->left, x, split_eq_to_left, comp);
    r = v;
  } else {
    std::tie(v->right, r) = split<N>((N*)v->right, x, split_eq_to_left, comp);
    l = v;
  }
  if (l) l->relax();
  if (r) r->relax();
  return std::make_pair(l, r);
}
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
std::tuple<N*, N*, N*> split3(N* tree, const typename N::key_t& x, Comp comp) {
  N *t1, *t2, *t12, *t3;
  std::tie(t12, t3) = split<N>(tree, x, true, comp);
  std::tie(t1, t2) = split<N>(t12, x, false, comp);
  return std::make_tuple(t1, t2, t3);
}
template <typename N>
N* merge(N* left, N* right) {
  if (left) left->push();
  if (right) right->push();
  if (!left) return right;
  if (!right) return left;
  if (left->priority < right->priority) {
    left->right = merge((N*)left->right, (N*)right);
    left->relax();
    return left;
  } else {
    right->left = merge((N*)left, (N*)right->left);
    right->relax();
    return right;
  }
}
template <typename N>
N* merge3(N* t1, N* t2, N* t3) {
  t2 = merge(t1, t2);
  t2 = merge(t2, t3);
  return t2;
}
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
N* insert(N* v, N* u, Comp comp) {
  N *t1, *t2;
  split(v, u->key, t1, t2, comp);
  t1 = merge(t1, u);
  return merge(t1, t2);
}
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
N* insert(N* v, typename N::key_t x, Comp comp) {
  return insert(v, &N(x), comp);
}
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
N* erase(N* v, N* u, Comp comp) {
  N *t1, *t2, *t3;
  std::tie(t1, t2, t3) = split3(v, u->key, comp);
  return merge(t1, t3);
}
template <typename N>
N* most_left_node(N* v) {
  if (!v) return nullptr;
  v->push();
  while (v->left != nullptr) {
    v = (N*)v->left;
    v->push();
  }
  return v;
}
template <typename N>
void delete_tree(N* v) {
  if (!v) return;
  delete_tree(v->left);
  delete_tree(v->right);
  delete v;
}
template <typename N,
          typename Comp = comparator::SpaceshipComparator<typename N::key_t>>
N* find(N* v, typename N::key_t key, Comp comp) {
  while (v) {
    comparator::Result res = comp(v->key, key);
    if (res == comparator::Result::EQUAL) break;
    if (res == comparator::Result::LESS) {
      v = v->left;
    } else {
      v = v->right;
    }
  }
  return v;
}
}  // namespace treap
}  // namespace opl
namespace opl {
namespace map {
template <typename K, typename V>
struct node : public treap::node<K, int> {
  node(const K& _key) : treap::node<K, int>(_key) {}
  std::size_t subtree_node_count = 1;
  V value;
  void push() {}
  static std::size_t getSubtreeNodeCount(node* v) {
    if (!v) return 0;
    return v->subtree_node_count;
  }
  void relax() {
    subtree_node_count = 1 + node::getSubtreeNodeCount((node*)this->left) +
                         node::getSubtreeNodeCount((node*)this->right);
  }
  static std::size_t position(node* tree, node* v) {
    if (!v) return node::getSubtreeNodeCount(tree);
    node *le, *gte;
    std::tie(le, gte) = treap::split(tree, v->key, false);
    auto ret = node::getSubtreeNodeCount(le);
    tree = treap::merge(le, gte);
    return ret;
  }
  static node* index(node* v, size_t i) {
    if (node::getSubtreeNodeCount(v) <= i) {
      return nullptr;
    }
    while (true) {
      std::size_t left_cnt = node::getSubtreeNodeCount(v->left);
      if (i == left_cnt) {
        return v;
      }
      if (i < left_cnt) {
        v = v->left;
        continue;
      }
      if (i > left_cnt) {
        v = v->right;
        i -= (left_cnt + 1);
      }
    }
  }
};
template <typename K, typename V>
struct map_iterator {
  using iterator_category = std::random_access_iterator_tag;
  using difference_type = std::size_t;
  using value_type = std::pair<const K&, V>;
  using reference = value_type&;
  using pointer = value_type*;
  using node_t = node<K, V>;
  node_t* tree_node = nullptr;
  node_t* tree = nullptr;
  value_type deref() const {
    return value_type(tree_node->key, tree_node->value);
  }
  value_type operator*() const { return deref(); }
  bool operator==(const map_iterator& other) const {
    return tree_node == other.tree_node && tree == other.tree;
  }
  bool operator!=(const map_iterator& other) const { return !(*this == other); }
  std::size_t position() const { return node_t::position(tree, tree_node); }
  difference_type operator-(const map_iterator& other) const {
    auto my_position = position();
    auto other_position = other.position();
    return my_position - other_position;
  }
};
template <typename K, typename V>
map_iterator<K, V> operator+(map_iterator<K, V> it, size_t x) {
  auto it_pos = it.position();
  auto new_pos = it_pos + x;
  auto new_node = node<K, V>::index(it.tree, x);
}
template <typename K, typename V, typename Less = std::less<K>>
class Map {
  using spaceship_comparator_t = comparator::SpaceshipComparator<K, Less>;
  using node_t = node<K, V>;
  mutable node_t* tree = nullptr;
  using key_t = K;
  using value_t = V;
  using iterator_t = map_iterator<key_t, value_t>;
  spaceship_comparator_t keyComparator;
  iterator_t constructIterator() const {
    iterator_t it;
    it.tree = tree;
    return it;
  }
  iterator_t constructIterator(node_t* v) const {
    iterator_t it = constructIterator();
    it.tree_node = v;
    return it;
  }

 public:
  using key_type = key_t;
  using value_type = value_t;
  using iterator_type = iterator_t;
  node_t* getTree() const { return tree; }
  void clear() {
    treap::delete_tree(tree);
    tree = nullptr;
  }
  void detach() { tree = nullptr; }
  iterator_t find(const key_t& key) const {
    node_t *t_lt, *t_eq, *t_gt;
    std::tie(t_lt, t_eq, t_gt) = treap::split3(tree, key, keyComparator);
    iterator_t it = constructIterator();
    it.tree_node = t_eq;
    tree = treap::merge3(t_lt, t_eq, t_gt);
    return it;
  }
  iterator_t bound(const key_t& key, bool is_upper) const {
    node_t *left, *right;
    std::tie(left, right) = treap::split(tree, key, is_upper, keyComparator);
    node_t* ret = treap::most_left_node(right);
    iterator_t it = constructIterator();
    it.tree_node = ret;
    tree = treap::merge(left, right);
    return it;
  }
  iterator_t lowerBound(const key_t& key) const { return bound(key, false); }
  iterator_t upperBound(const key_t& key) const { return bound(key, true); }
  iterator_t begin() const {
    iterator_t it = constructIterator(treap::most_left_node(tree));
    return it;
  }
  iterator_t end() const {
    iterator_t it = constructIterator();
    it.tree_node = nullptr;
    return it;
  }
  bool erase(const key_t& key) {
    node_t *lt, *eq, *gt;
    std::tie(lt, eq, gt) = treap::split3(tree, key, keyComparator);
    if (!eq) {
      return false;
    }
    delete eq;
    tree = treap::merge(lt, gt);
    return true;
  }
  bool erase(iterator_t it) { return erase((*it).first); }
  std::pair<iterator_t, bool> insert(const key_t& key, const value_t& value) {
    node_t *lt, *eq, *gt;
    std::tie(lt, eq, gt) = treap::split3(tree, key, keyComparator);
    bool new_node_created = false;
    if (!eq) {
      new_node_created = true;
      eq = new node_t(key);
    }
    eq->value = value;
    tree = treap::merge3(lt, eq, gt);
    iterator_t it = constructIterator();
    it.tree_node = eq;
    return std::make_pair(it, new_node_created);
  }
  std::pair<iterator_t, bool> insert(const key_t& key) {
    return insert(key, value_t());
  }
  int count(const key_t& key) const {
    node_t *lt, *eq, *gt;
    std::tie(lt, eq, gt) = treap::split3(tree, key, keyComparator);
    int ret = 0;
    if (eq) ret = 1;
    tree = treap::merge3(lt, eq, gt);
    return ret;
  }
  size_t size() const { return node_t::getSubtreeNodeCount(tree); }
  bool empty() const { return size() == 0; }
};
}  // namespace map
template <typename K, typename V>
using Map = map::Map<K, V>;
}  // namespace opl
using namespace std;
template <typename... Vectors>
void resizeVectors(int newSize, Vectors&... vectors) {
  (vectors.resize(newSize), ...);
}
void resizeVectors(int unusedNewSize) {}
template <typename... Vectors>
void readEntryHelper(int i, Vectors&... vectors) {
  ((cin >> vectors[i]), ...);
}
template <typename... Vectors>
void readVectors(int count, Vectors&... vectors) {
  (resizeVectors(count, (vectors, ...)));
  for (int i = 0; i < count; ++i) {
    (readEntryHelper(i, (vectors, ...)));
  }
}
using ll = signed long long;
using ld = long double;
void $main();
int main() {
  int numTests = 1;
  if (0) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> numTests;
  } else {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  }
  for (int i = 0; i < numTests; ++i) {
    $main();
    if (0) {
      cout << "-----\n";
    }
  }
}
using P = pair<ll, int>;
void $main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, ll>>> g(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    --u;
    --v;
    g[u].emplace_back(v, w);
    g[v].emplace_back(u, w);
  }
  vector<ll> a;
  readVectors(n, a);
  vector<ll> ans(a);
  opl::map::Map<P, double> q;
  for (int i = 0; i < n; ++i) {
    q.insert(P(ans[i], i));
  }
  while (!q.empty()) {
    auto ev = (*q.begin()).first;
    q.erase(ev);
    auto [ansv, v] = ev;
    if (ansv > ans[v]) continue;
    for (auto edge : g[v]) {
      ll nans = ans[v] + 2 * edge.second;
      ll& cans = ans[edge.first];
      if (cans > nans) {
        cans = nans;
        q.insert(P(cans, edge.first));
      }
    }
  }
  for (ll x : ans) cout << x << " ";
  cout << "\n";
}
