#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15 + 5;
int n;
int c[100000 + 5][3];
int deg[100000 + 5];
int hed[100000 + 5];
int to[100000 * 2 + 5];
int nex[100000 * 2 + 5];
int vis[100000 + 5];
int etot;
int net[100000 + 5];
int qs;
int qt;
int Q[100000 + 5];
int mak[100000 + 5];
void addedge(int u, int v) {
  to[etot] = v;
  nex[etot] = hed[u];
  hed[u] = etot++;
}
int main() {
  fill(hed, hed + 100001, -1);
  etot = 0;
  qs = qt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i][0]);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i][1]);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i][2]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    deg[u]++;
    deg[v]++;
    addedge(u, v);
    addedge(v, u);
  }
  int p;
  for (int i = 1; i <= n; i++) {
    if (p != -1 && deg[i] == 1) p = i;
    if (deg[i] > 2) p = -1;
  }
  if (p == -1)
    printf("-1\n");
  else {
    Q[qt++] = p;
    vis[p] = 1;
    while (qs != qt) {
      int u = Q[qs++];
      for (int i = hed[u]; i != -1; i = nex[i]) {
        int v = to[i];
        if (vis[v]) continue;
        vis[v] = 1;
        net[u] = v;
        Q[qt++] = v;
      }
    }
    long long ans = inf;
    long long tmp = 0;
    int swen = 0;
    int tp;
    int flag;
    for (int i = p; i; i = net[i], swen = (swen + 1) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 0, flag = 1;
    swen = 0;
    tmp = 0;
    for (int i = p; i; i = net[i], swen = (swen + 2) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 0, flag = 0;
    swen = 1;
    tmp = 0;
    for (int i = p; i; i = net[i], swen = (swen + 1) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 1, flag = 1;
    swen = 1;
    tmp = 0;
    for (int i = p; i; i = net[i], swen = (swen + 2) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 1, flag = 0;
    swen = 2;
    tmp = 0;
    for (int i = p; i; i = net[i], swen = (swen + 1) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 2, flag = 1;
    swen = 2;
    tmp = 0;
    for (int i = p; i; i = net[i], swen = (swen + 2) % 3) {
      tmp += 1ll * c[i][(swen)];
    }
    if (ans > tmp) ans = tmp, tp = 2, flag = 0;
    swen = tp;
    int x = (flag == 1 ? 1 : 2);
    for (int i = p; i; i = net[i], swen = (swen + x) % 3) {
      mak[i] = swen;
    }
    printf("%I64d\n", ans);
    for (int i = 1; i <= n; i++) printf("%d ", mak[i] + 1);
  }
  return 0;
}
