#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} pre[200010][3][3];
long long dp[200010][3][3];
long long a[200010][3];
int head[200010], vet[200010], nxt[200010], d[200010], c[200010], son[200010],
    f[200010], tot, n;
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
void add(int a, int b) {
  nxt[++tot] = head[a];
  vet[tot] = b;
  head[a] = tot;
}
void dfs(int u, int fa) {
  int e = head[u], s = 0;
  for (int i = (int)0; i <= (int)2; i++)
    for (int j = (int)0; j <= (int)2; j++) dp[u][i][j] = 1e15;
  while (e) {
    int v = vet[e];
    if (v != fa) {
      s++;
      son[u] = v;
      f[v] = u;
      dfs(v, u);
    }
    e = nxt[e];
  }
  if (u == 1 && d[1] == 2) {
    return;
  }
  if (s == 0) {
    for (int i = (int)0; i <= (int)2; i++)
      for (int j = (int)0; j <= (int)2; j++)
        if (i != j) dp[u][i][j] = a[u][i];
  } else {
    int v = son[u];
    for (int i = (int)0; i <= (int)2; i++)
      for (int j = (int)0; j <= (int)2; j++)
        for (int k = (int)0; k <= (int)2; k++)
          if (i != j && j != k && i != k) {
            if (dp[u][i][j] > dp[v][j][k] + a[u][i]) {
              dp[u][i][j] = dp[v][j][k] + a[u][i];
              pre[u][i][j].x = j;
              pre[u][i][j].y = k;
            }
          }
  }
}
void print() {
  if (d[1] == 1) {
    long long ans = 1e15;
    int x = 0, y = 0;
    for (int i = (int)0; i <= (int)2; i++)
      for (int j = (int)0; j <= (int)2; j++)
        if (i != j && dp[1][i][j] < ans) {
          ans = dp[1][i][j];
          x = i;
          y = j;
        }
    int u = 1;
    while (u) {
      c[u] = x;
      int x1 = pre[u][x][y].x;
      int y1 = pre[u][x][y].y;
      u = son[u];
      x = x1, y = y1;
    }
    printf("%I64d\n", ans);
    for (int i = (int)1; i <= (int)n; i++) printf("%d ", c[i] + 1);
  } else {
    int k1 = 0, k2 = 0;
    for (int i = (int)1; i <= (int)n; i++)
      if (f[i] == 1) {
        k1 = i;
        break;
      }
    for (int i = (int)n; i >= (int)1; i--)
      if (f[i] == 1) {
        k2 = i;
        break;
      }
    int x1, y1, x2, y2, z;
    long long ans = 1e15;
    for (int i = (int)0; i <= (int)2; i++)
      for (int j = (int)0; j <= (int)2; j++)
        for (int k = (int)0; k <= (int)2; k++)
          for (int p = (int)0; p <= (int)2; p++)
            for (int q = (int)0; q <= (int)2; q++)
              if (i != j && i != k && j != k && j != p && p != i && i != q &&
                  k != q && dp[k1][j][p] + dp[k2][k][q] + a[1][i] < ans) {
                ans = dp[k1][j][p] + dp[k2][k][q] + a[1][i];
                z = i;
                x1 = j;
                y1 = p;
                x2 = k;
                y2 = q;
              }
    c[1] = z;
    int u = k1, x = x1, y = y1;
    while (u) {
      c[u] = x;
      int x1 = pre[u][x][y].x;
      int y1 = pre[u][x][y].y;
      u = son[u];
      x = x1, y = y1;
    }
    u = k2, x = x2, y = y2;
    while (u) {
      c[u] = x;
      int x1 = pre[u][x][y].x;
      int y1 = pre[u][x][y].y;
      u = son[u];
      x = x1, y = y1;
    }
    printf("%I64d\n", ans);
    for (int i = (int)1; i <= (int)n; i++) printf("%d ", c[i] + 1);
  }
}
int main() {
  n = read();
  for (int j = (int)0; j <= (int)2; j++)
    for (int i = (int)1; i <= (int)n; i++) scanf("%I64d", &a[i][j]);
  for (int i = (int)1; i <= (int)n; i++) head[i] = d[i] = 0;
  tot = 0;
  for (int i = (int)1; i <= (int)n - 1; i++) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
    d[x]++;
    d[y]++;
  }
  int flag = 1;
  for (int i = (int)1; i <= (int)n; i++)
    if (d[i] >= 3) flag = 0;
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  dfs(1, 0);
  print();
  return 0;
}
