Problem: Thought it is already the XXI century, the Mass Media isn't very popular in Walrusland. The cities get news from messengers who can only travel along roads. The network of roads in Walrusland is built so that it is possible to get to any city from any other one in exactly one way, and the roads' lengths are equal.

The North Pole governor decided to carry out an information reform. Several cities were decided to be chosen and made regional centers. Maintaining a region center takes k fishlars (which is a local currency) per year. It is assumed that a regional center always has information on the latest news.

For every city which is not a regional center, it was decided to appoint a regional center which will be responsible for keeping this city informed. In that case the maintenance costs will be equal to dlen fishlars per year, where len is the distance from a city to the corresponding regional center, measured in the number of roads along which one needs to go.

Your task is to minimize the costs to carry out the reform.

Input

The first line contains two given numbers n and k (1 ≤ n ≤ 180, 1 ≤ k ≤ 105).

The second line contains n - 1 integers di, numbered starting with 1 (di ≤ di + 1, 0 ≤ di ≤ 105).

Next n - 1 lines contain the pairs of cities connected by a road.

Output

On the first line print the minimum number of fishlars needed for a year's maintenance. On the second line print n numbers, where the i-th number will represent the number of the regional center, appointed to the i-th city. If the i-th city is a regional center itself, then you should print number i.

If there are several solutions to that problem, print any of them.

Examples

Input

8 10
2 5 9 11 15 19 20
1 4
1 3
1 7
4 6
2 8
2 3
3 5


Output

38
3 3 3 4 3 4 3 3 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int Imx = 2147483647;
const long long Lbig = 2e18;
const int mod = 1e9 + 7;
struct fastio {
  char s[100000];
  int it, len;
  fastio() { it = len = 0; }
  inline char get() {
    if (it < len) return s[it++];
    it = 0;
    len = fread(s, 1, 100000, stdin);
    if (len == 0)
      return EOF;
    else
      return s[it++];
  }
  bool notend() {
    char c = get();
    while (c == ' ' || c == '\n') c = get();
    if (it > 0) it--;
    return c != EOF;
  }
} _buff;
inline long long getnum() {
  long long r = 0;
  bool ng = 0;
  char c;
  c = _buff.get();
  while (c != '-' && (c < '0' || c > '9')) c = _buff.get();
  if (c == '-') ng = 1, c = _buff.get();
  while (c >= '0' && c <= '9') r = r * 10 + c - '0', c = _buff.get();
  return ng ? -r : r;
}
template <class T>
inline void putnum(T x) {
  if (x < 0) putchar('-'), x = -x;
  register short a[20] = {}, sz = 0;
  while (x) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
inline char getreal() {
  char c = _buff.get();
  while (c <= 32) c = _buff.get();
  return c;
}
int tot = 0;
int ti[1000000], tj[1000000], tk[1000000];
vector<int> pv[1000000];
struct value {
  int v;
  int id;
  void update(value a) {
    if (a.v < v) {
      v = a.v;
      pv[id].clear();
      pv[id].push_back(a.id);
    }
  }
  void update(value a, value b) {
    if (a.v + b.v < v) {
      v = a.v + b.v;
      pv[id].clear();
      pv[id].push_back(a.id);
      pv[id].push_back(b.id);
    }
  }
};
value newv(int i = -1, int j = -1, int k = -1) {
  value ret;
  ret.id = ++tot;
  ret.v = 1 << 29;
  ti[tot] = i;
  tj[tot] = j;
  tk[tot] = k;
  return ret;
}
int n, m;
int cd[233];
vector<int> con[233];
value dp[233][233][3];
void dfs(int x, int pre = -1) {
  for (int i = 0; i <= n + 2; i++) {
    dp[x][i][0] = newv(x, i, 0);
    dp[x][i][1] = newv(x, i, 1);
  }
  for (int i = 0; i < con[x].size(); i++) {
    int u = con[x][i];
    if (u == pre) continue;
    dfs(u, x);
  }
  for (int d = 1; d <= n; d++) {
    value wu0 = newv();
    value wu1 = newv();
    value wd = newv();
    wu0.v = cd[d];
    wu1.v = 1 << 28;
    wd.v = cd[d];
    for (int i = 0; i < con[x].size(); i++) {
      int u = con[x][i];
      if (u == pre) continue;
      value nwd = newv();
      nwd.update(wd, dp[u][d + 1][1]);
      nwd.update(wd, dp[u][d][0]);
      value nwu1 = newv();
      value tmp = newv();
      tmp.update(wu0, dp[u][d - 1][0]);
      tmp.update(wu1, dp[u][d - 1][0]);
      value tmp2 = newv();
      tmp2.update(dp[u][d + 1][1]);
      tmp2.update(dp[u][d][0]);
      nwu1.update(wu1, tmp2);
      nwu1.update(tmp);
      value nwu0 = newv();
      nwu0.update(wu0, tmp2);
      swap(wu0, nwu0);
      swap(wu1, nwu1);
      swap(wd, nwd);
    }
    dp[x][d][0].update(wu1);
    dp[x][d][1].update(wd);
  }
  dp[x][0][0].v = cd[0];
  for (int i = 0; i < con[x].size(); i++) {
    int u = con[x][i];
    if (u == pre) continue;
    value nv = newv();
    nv.update(dp[x][0][0], dp[u][1][1]);
    nv.update(dp[x][0][0], dp[u][0][0]);
    swap(nv, dp[x][0][0]);
  }
  for (int i = n; i >= 0; i--) {
    dp[x][i][1].update(dp[x][i][0]);
  }
}
bool vis[1000000];
bool center[233];
void findans(int x) {
  vis[x] = 1;
  for (int i = 0; i < pv[x].size(); i++) {
    if (!vis[pv[x][i]]) {
      findans(pv[x][i]);
    }
  }
  if (tj[x] == 0) {
    center[ti[x]] = 1;
  }
}
int q[233], qn;
int g[233];
int main() {
  n = getnum(), cd[0] = getnum();
  for (int i = 1; i < n; i++) cd[i] = getnum();
  for (int i = 1; i < n; i++) {
    int x, y;
    x = getnum(), y = getnum();
    con[x].push_back(y);
    con[y].push_back(x);
  }
  dfs(1);
  int mn = mod, mnid = 0;
  for (int i = 0; i <= n; i++) {
    if (dp[1][i][0].v < mn) {
      mn = dp[1][i][0].v;
      mnid = i;
    }
  }
  cout << mn << endl;
  findans(dp[1][mnid][0].id);
  for (int i = 1; i <= n; i++) {
    vis[i] = 0;
    if (center[i]) {
      q[qn++] = i;
      g[i] = i;
      vis[i] = 1;
    }
  }
  for (int i = 0; i < qn; i++) {
    int u = q[i];
    for (int j = 0; j < con[u].size(); j++) {
      int v = con[u][j];
      if (!vis[v]) {
        vis[v] = 1;
        g[v] = g[u];
        q[qn++] = v;
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << g[i] << " ";
  cout << endl;
  return 0;
}