#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const long long INF = 1000000000000000;
int n;
long long cost[MAXN + 5][5];
int edge[MAXN + 5][5];
int a[MAXN + 5], pr[MAXN + 5];
bool vis[MAXN + 5];
void dfs(int x, int id) {
  a[id] = x;
  vis[x] = true;
  for (int i = 1; i <= edge[x][0]; i++) {
    int y = edge[x][i];
    if (!vis[y]) dfs(y, id + 1);
  }
}
void work() {
  long long ans = INF;
  int ansx, ansy;
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (i == j) continue;
      long long tmp = cost[a[1]][i] + cost[a[2]][j];
      int x = i, y = j;
      for (int k = 3; k <= n; k++) {
        tmp += cost[a[k]][6 - x - y];
        int t = 6 - x - y;
        x = y;
        y = t;
      }
      if (tmp < ans) {
        ans = tmp;
        ansx = i;
        ansy = j;
      }
    }
  }
  printf("%I64d\n", ans);
  pr[a[1]] = ansx;
  pr[a[2]] = ansy;
  for (int i = 3; i <= n; i++) {
    int t = 6 - ansx - ansy;
    pr[a[i]] = t;
    ansx = ansy;
    ansy = t;
  }
  for (int i = 1; i <= n; i++) {
    printf("%d", pr[i]);
    if (i < n) putchar(' ');
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= n; j++) scanf("%I64d", &cost[j][i]);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u][++edge[u][0]] = v;
    edge[v][++edge[v][0]] = u;
    if (edge[u][0] > 2 || edge[v][0] > 2) {
      printf("-1\n");
      return 0;
    }
  }
  int be;
  for (int i = 1; i <= n; i++)
    if (edge[i][0] == 1) be = i;
  dfs(be, 1);
  work();
  return 0;
}
