#include <bits/stdc++.h>
using namespace std;
const int maxn = 100003;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
vector<int> g[maxn];
int a[maxn], b[maxn], c[maxn], n, p[maxn], cnt, pre[maxn][9], ANS[maxn];
long long dp[maxn][9];
void init(int u, int last) {
  p[++cnt] = u;
  for (int v : g[u])
    if (v != last) init(v, u);
}
void chk(int u, int i, int v, int j) { dp[u][i] = dp[v][j], pre[u][i] = j; }
void output(int i, int j) {
  if (i == 0) return;
  ANS[p[i]] = j % 3 + 1;
  output(i - 1, pre[p[i]][j]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (g[i].size() >= 3) {
      puts("-1");
      return 0;
    }
  p[++cnt] = 1;
  if (g[1].size() >= 1) init(g[1][0], 1);
  reverse(p + 1, p + cnt + 1);
  if (g[1].size() == 2) init(g[1][1], 1);
  for (int i = 1; i <= cnt; i++) {
    int u = p[i], v = p[i - 1];
    chk(u, 1, v, 6);
    chk(u, 2, v, 3);
    chk(u, 3, v, 7);
    chk(u, 5, v, 1);
    chk(u, 6, v, 5);
    chk(u, 7, v, 2);
    dp[u][1] += b[u], dp[u][2] += c[u];
    dp[u][3] += a[u], dp[u][5] += c[u];
    dp[u][6] += a[u], dp[u][7] += b[u];
  }
  long long ans = INF, pos;
  if (dp[p[cnt]][1] < ans) ans = dp[p[cnt]][1], pos = 1;
  if (dp[p[cnt]][2] < ans) ans = dp[p[cnt]][2], pos = 2;
  if (dp[p[cnt]][3] < ans) ans = dp[p[cnt]][3], pos = 3;
  if (dp[p[cnt]][5] < ans) ans = dp[p[cnt]][5], pos = 5;
  if (dp[p[cnt]][6] < ans) ans = dp[p[cnt]][6], pos = 6;
  if (dp[p[cnt]][7] < ans) ans = dp[p[cnt]][7], pos = 7;
  output(cnt, pos);
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) printf("%d ", ANS[i]);
  return 0;
}
