#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
int n;
long long c[4][N];
struct Edge {
  int v, nxt;
} e[N << 1];
int head[N], etot;
int deg[N], mxdeg, root;
int a[N], tot, mp[N];
int t[3];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
inline void adde(int u, int v) {
  e[++etot].nxt = head[u], e[etot].v = v, head[u] = etot;
}
inline void smax(int &x, int y) { x = x < y ? y : x; }
inline void dfs(int p, int fa) {
  a[++tot] = p;
  mp[p] = tot;
  for (int i = head[p]; ~i; i = e[i].nxt) {
    int v = e[i].v;
    if (v ^ fa) {
      dfs(v, p);
    }
  }
}
long long ans = 1e18;
int mk[N];
inline void update(int *t) {
  long long sum = 0;
  for (register int i = 1; i <= n; ++i) sum += c[t[i % 3]][a[i]];
  if (ans > sum) {
    ans = sum;
    for (register int i = 1; i <= n; ++i) mk[i] = t[i % 3];
  }
}
int main() {
  memset(head, -1, sizeof(head));
  n = read();
  for (register int i = 1; i <= n; ++i) c[1][i] = read();
  for (register int i = 1; i <= n; ++i) c[2][i] = read();
  for (register int i = 1; i <= n; ++i) c[3][i] = read();
  for (register int i = 1; i < n; ++i) {
    int u = read(), v = read();
    adde(u, v);
    adde(v, u);
    ++deg[u], ++deg[v];
  }
  for (register int i = 1; i <= n; ++i) {
    smax(mxdeg, deg[i]);
    if (deg[i] == 1) {
      root = i;
    }
  }
  if (mxdeg > 2) {
    puts("-1");
    return 0;
  }
  dfs(root, 0);
  t[0] = 1, t[1] = 2, t[2] = 3;
  update(t);
  t[0] = 1, t[1] = 3, t[2] = 2;
  update(t);
  t[0] = 2, t[1] = 1, t[2] = 3;
  update(t);
  t[0] = 2, t[1] = 3, t[2] = 1;
  update(t);
  t[0] = 3, t[1] = 1, t[2] = 2;
  update(t);
  t[0] = 3, t[1] = 2, t[2] = 1;
  update(t);
  printf("%lld\n", ans);
  for (register int i = 1; i <= n; ++i) printf("%d ", mk[mp[i]]);
  return 0;
}
