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;
struct Stanje {
  int x, u, d;
  Stanje() {}
  Stanje(int X, int U, int D) : x(X), u(U), d(D) {}
};
vector<int> node[184];
vector<int> v;
int dp[184][184][184];
int dp2[184][184][184];
Stanje parent[184][184][184];
int parent2[184][184][184];
int dfsparent[184];
int cost[184];
int height[184];
int center[184];
bool bio[184];
int N;
vector<int> c;
bool bfsbio[184];
void DFS(int x, int parent = -1) {
  bio[x] = true;
  for (vector<int>::iterator it = node[x].begin(); it != node[x].end(); ++it) {
    if (bio[*it]) continue;
    DFS(*it, x);
    if (height[*it] + 1 > height[x]) height[x] = height[*it] + 1;
  }
  if (x > 1) {
    dfsparent[x] = parent;
    node[x].erase(find(node[x].begin(), node[x].end(), parent));
  }
  v.push_back(x);
}
vector<int> stek;
void reconstruct(int x, int u, int d) {
  if (d == 0) c.push_back(x);
  if (height[x] == 0) return;
  stek.push_back(x);
  for (int i = 0; i < node[x].size(); ++i) {
    int y = node[x][i];
    Stanje S;
    if (parent[x][u][d].x == y) {
      S = parent[x][u][d];
    } else if (d > 0)
      S = Stanje(node[x][i], min(u, d) + 1, parent2[y][min(u, d) + 1][N]);
    else {
      S = Stanje(node[x][i], 1, parent2[y][1][parent[x][u][d].d]);
    }
    reconstruct(S.x, S.u, S.d);
  }
  stek.pop_back();
}
void BFS(void) {
  queue<int> q;
  memset(bfsbio, 0, sizeof(bfsbio));
  for (int i = 2; i <= N; ++i) node[i].push_back(dfsparent[i]);
  for (int i = 0; i < c.size(); ++i) {
    q.push(c[i]);
    center[c[i]] = c[i];
    bfsbio[c[i]] = true;
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < node[x].size(); ++i) {
      int y = node[x][i];
      if (bfsbio[y]) continue;
      bfsbio[y] = true;
      center[y] = center[x];
      q.push(y);
    }
  }
}
int main(void) {
  int A, B;
  memset(cost, 0x3f, sizeof(cost));
  scanf("%d%d", &N, &cost[0]);
  for (int i = 1; i < N; ++i) scanf("%d", cost + i);
  for (int i = 1; i < N; ++i) {
    scanf("%d%d", &A, &B);
    node[A].push_back(B);
    node[B].push_back(A);
  }
  memset(dp, 0x3f, sizeof(dp));
  memset(dp2, 0x3f, sizeof(dp2));
  DFS(1);
  for (int I = 0; I < N; ++I) {
    int x = v[I];
    for (int u = 1; u <= N; ++u)
      for (int d = 0; d <= N; ++d) {
        if (d > height[x] && d < N) continue;
        int best = node[x].empty() ? 0 : 1000000000;
        Stanje best_parent;
        if (d > 0) {
          int sum = 0;
          for (int i = 0; i < node[x].size(); ++i)
            sum += dp2[node[x][i]][min(u, d) + 1][N];
          for (int i = 0; i < node[x].size(); ++i) {
            int y = node[x][i];
            int tmp = dp[y][min(u + 1, N)][d == N ? N : d - 1] + sum -
                      dp2[y][min(u, d) + 1][N];
            if (tmp < best) {
              best = tmp;
              best_parent = Stanje(y, min(u + 1, N), d == N ? N : d - 1);
            }
          }
        } else {
          for (int h = 0; h <= N; ++h) {
            int sum = 0;
            for (int i = 0; i < node[x].size(); ++i)
              sum += dp2[node[x][i]][1][h];
            for (int i = 0; i < node[x].size(); ++i) {
              int y = node[x][i];
              int tmp = dp[y][1][h] + sum - dp2[y][1][h];
              if (tmp < best) {
                best = tmp;
                best_parent = Stanje(y, 1, h);
              }
            }
          }
        }
        best += cost[min(u, d)];
        if (best > 1000000000) best = 1000000000;
        for (int i = d; i <= N; ++i)
          if (best < dp2[x][u][i]) {
            dp2[x][u][i] = best;
            parent2[x][u][i] = d;
          }
        dp[x][u][d] = best;
        parent[x][u][d] = best_parent;
      }
  }
  int best = 1000000000;
  Stanje S;
  for (int i = 0; i < N; ++i) {
    int tmp = dp[1][N][i];
    if (tmp < best) {
      best = tmp;
      S = Stanje(1, N, i);
    }
  }
  printf("%d\n", best);
  reconstruct(S.x, S.u, S.d);
  BFS();
  for (int i = 1; i <= N; ++i) printf("%d ", center[i]);
  printf("\n");
  return 0;
}