#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10, MAXM = 2e5 + 10;
struct Edge {
  int u, v;
} edge[MAXM];
int first[MAXN], Cry_For_theMoon[MAXM], tot;
int n, c[MAXN][4], u, v, size[MAXN], head;
int pre[MAXN], nxt[MAXN], color[MAXN];
long long sum, ans = 1e18, sol[MAXN];
void addedge(int u, int v) {
  edge[++tot].u = u;
  edge[tot].v = v;
  Cry_For_theMoon[tot] = first[u];
  first[u] = tot;
}
int main() {
  cin >> n;
  for (long long i = (1); i <= (3); i++) {
    for (long long j = (1); j <= (n); j++) cin >> c[j][i];
  }
  for (long long i = (1); i <= (n - 1); i++) {
    cin >> u >> v;
    addedge(u, v), addedge(v, u);
    size[u]++;
    size[v]++;
    if (size[u] >= 3 || size[v] >= 3) {
      printf("-1\n");
      return 0;
    }
  }
  for (long long i = (1); i <= (n); i++)
    if (size[i] == 1) head = i;
  int now = head;
  for (long long i = (1); i <= (n); i++) {
    for (int j = first[now]; j; j = Cry_For_theMoon[j]) {
      int v = edge[j].v;
      if (v == pre[now]) continue;
      nxt[now] = v;
      pre[v] = now;
    }
    now = nxt[now];
  }
  for (long long c1 = (1); c1 <= (3); c1++) {
    for (long long c2 = (1); c2 <= (3); c2++) {
      if (c1 == c2) continue;
      int c3 = 1;
      if (c1 == 1 || c2 == 1) {
        c3++;
        if (c1 == 2 || c2 == 2) {
          c3++;
        }
      }
      now = head;
      sum = 0;
      int cnt = 1;
      while (now) {
        if (cnt % 3 == 1)
          color[now] = c1;
        else if (cnt % 3 == 2)
          color[now] = c2;
        else
          color[now] = c3;
        sum += c[now][color[now]];
        now = nxt[now];
        cnt++;
      }
      if (sum < ans) {
        for (long long i = (1); i <= (n); i++) sol[i] = color[i];
        ans = sum;
      }
    }
  }
  printf("%lld\n", ans);
  for (long long i = (1); i <= (n); i++) {
    printf("%d ", sol[i]);
  }
  return 0;
}
