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 rec {
  int x;
  rec *next;
};
rec a[200];
int c[200];
int d[200][200][2];
int pp[200];
int used[200];
int price[200];
int center[200];
int cc[200][200][2];
int n;
int solve(int i, int j, int k, int up) {
  int ni, nj, nk, tmp, min, skip;
  rec *p;
  if (j == 0) {
    center[i] = i;
    up = i;
  } else if (k == 0)
    center[i] = up;
  else
    center[i] = -1;
  if ((k == 0) || (cc[i][j][k] == -1)) {
  } else {
    ni = cc[i][j][k];
    nj = j - 1;
    nk = 1;
    tmp = solve(ni, nj, nk, up);
    center[i] = tmp;
    up = center[i];
  }
  p = a[i].next;
  while (p != NULL) {
    if (pp[p->x] == i) {
      min = d[p->x][j][1];
      ni = p->x;
      nj = j;
      nk = 1;
      if ((j + 1 < n) && (d[p->x][j + 1][1] < min)) {
        min = d[p->x][j + 1][1];
        ni = p->x;
        nj = j + 1;
        nk = 1;
      }
      if ((j + 1 < n) && (d[p->x][j + 1][0] < min)) {
        min = d[p->x][j + 1][0];
        ni = p->x;
        nj = j + 1;
        nk = 0;
      }
      if ((j - 1 >= 0) && (d[p->x][j - 1][1] <= min)) {
        min = d[p->x][j - 1][1];
        ni = p->x;
        nj = j - 1;
        nk = 1;
      }
      skip = 0;
      if ((k == 0) || (cc[i][j][k] == -1)) {
      } else {
        if (p->x == cc[i][j][k]) {
          skip = 1;
        }
      }
      if (skip == 0) {
        tmp = solve(ni, nj, nk, up);
        if ((nk == 1) && (nj == j - 1) && (center[i] == -1)) center[i] = tmp;
      }
    }
    p = p->next;
  }
  return center[i];
}
int main() {
  int i, j, ii, k, tot, min, x, y, delta, ans, top, bottom, iszero, allzero, bi;
  rec *p;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) a[i].next = NULL;
  for (i = 1; i < n; i++) scanf("%d", &price[i]);
  price[0] = k;
  for (i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    p = new rec();
    p->x = y;
    p->next = a[x].next;
    a[x].next = p;
    p = new rec();
    p->x = x;
    p->next = a[y].next;
    a[y].next = p;
  }
  memset(used, 0, sizeof(used));
  c[0] = 0;
  pp[0] = -1;
  used[0] = 1;
  top = 0;
  bottom = 1;
  while (top < bottom) {
    p = a[c[top]].next;
    while (p != NULL) {
      if (used[p->x] == 0) {
        pp[p->x] = c[top];
        used[p->x] = 1;
        c[bottom] = p->x;
        bottom++;
      }
      p = p->next;
    }
    top++;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      d[i][j][0] = 2000000000;
      d[i][j][1] = 2000000000;
    }
  for (ii = bottom - 1; ii >= 0; ii--) {
    i = c[ii];
    for (j = 0; j < n; j++) {
      allzero = 1;
      p = a[i].next;
      tot = 0;
      while (p != NULL) {
        if (pp[p->x] == i) {
          min = d[p->x][j][1];
          if ((j + 1 < n) && (d[p->x][j + 1][1] < min)) min = d[p->x][j + 1][1];
          if ((j + 1 < n) && (d[p->x][j + 1][0] < min)) min = d[p->x][j + 1][0];
          iszero = 1;
          if ((j - 1 >= 0) && (d[p->x][j - 1][1] <= min)) {
            min = d[p->x][j - 1][1];
            bi = p->x;
            iszero = 0;
          }
          if (min == 2000000000) {
            tot = 2000000000;
            break;
          }
          tot += min;
          if (iszero == 0) allzero = 0;
        }
        p = p->next;
      }
      if (tot == 2000000000) continue;
      d[i][j][0] = tot + price[j];
      if ((allzero == 0) || (j == 0)) {
        d[i][j][1] = tot + price[j];
        if (allzero == 0)
          cc[i][j][1] = bi;
        else
          cc[i][j][1] = -1;
      } else {
        delta = 2000000000;
        p = a[i].next;
        while (p != NULL) {
          if (pp[p->x] == i) {
            min = d[p->x][j][1];
            if ((j + 1 < n) && (d[p->x][j + 1][1] < min))
              min = d[p->x][j + 1][1];
            if ((j + 1 < n) && (d[p->x][j + 1][0] < min))
              min = d[p->x][j + 1][0];
            if ((j - 1 >= 0) && (d[p->x][j - 1][1] != 2000000000)) {
              if (d[p->x][j - 1][1] - min < delta) {
                delta = d[p->x][j - 1][1] - min;
                bi = p->x;
              }
            }
          }
          p = p->next;
        }
        if (delta != 2000000000) {
          d[i][j][1] = tot + delta + price[j];
          cc[i][j][1] = bi;
        }
      }
    }
  }
  ans = 2000000000;
  for (i = 0; i < n; i++)
    if (d[0][i][1] < ans) {
      ans = d[0][i][1];
      bi = i;
    }
  printf("%d\n", ans);
  solve(0, bi, 1, -1);
  for (i = 0; i < n; i++) {
    if (i != 0) printf(" ");
    printf("%d", center[i] + 1);
  }
  printf("\n");
  return 0;
}