#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const long long INF = 1e18;
int N, c1[MAXN], c2[MAXN], c3[MAXN];
int col[MAXN], bg, dfn[MAXN], Cnt;
long long Ans = INF;
vector<int> P[MAXN];
void DFS(int u, int fa) {
  dfn[++Cnt] = u;
  int size = P[u].size();
  for (int i = 0; i < size; i++) {
    int v = P[u][i];
    if (v == fa) continue;
    DFS(v, u);
  }
}
int A[MAXN], vis[5];
void DFS2(int x) {
  if (x == 3) {
    long long rt = 0;
    for (int i = 1; i <= N; i++) {
      if (A[i % 3] == 1) rt += c1[dfn[i]];
      if (A[i % 3] == 2) rt += c2[dfn[i]];
      if (A[i % 3] == 3) rt += c3[dfn[i]];
    }
    if (rt < Ans) {
      Ans = rt;
      for (int i = 1; i <= N; i++) col[dfn[i]] = A[i % 3];
    }
    return;
  }
  for (int i = 1; i <= 3; i++)
    if (!vis[i]) vis[i] = 1, A[x] = i, DFS2(x + 1), vis[i] = 0;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", &c1[i]);
  for (int i = 1; i <= N; i++) scanf("%d", &c2[i]);
  for (int i = 1; i <= N; i++) scanf("%d", &c3[i]);
  for (int i = 1, x, y; i < N; i++) {
    scanf("%d%d", &x, &y);
    P[x].push_back(y);
    P[y].push_back(x);
  }
  for (int i = 1; i <= N; i++)
    if (P[i].size() >= 3) {
      printf("-1\n");
      return 0;
    }
  for (int i = 1; i <= N; i++)
    if (P[i].size() == 1) {
      bg = i;
      break;
    }
  DFS(bg, 0);
  DFS2(0);
  printf("%lld\n", Ans);
  for (int i = 1; i <= N; i++) printf("%d ", col[i]);
  puts("");
}
