#include <bits/stdc++.h>
const int mxn = 1e5;
int cost[mxn][3], go[mxn][2], deg[mxn], path[mxn];
int color[mxn];
long long cc[3][3];
int main() {
  int n, u, a, b, c = 0;
  scanf("%d", &n);
  for (int j = 0; j < 3; ++j)
    for (int i = 1; i <= n; ++i) scanf("%d", &cost[i][j]);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &a, &b);
    ++deg[a], ++deg[b];
    go[a][0] ? go[a][1] = b : go[a][0] = b;
    go[b][0] ? go[b][1] = a : go[b][0] = a;
  }
  for (int i = 1; i <= n; ++i) {
    if (deg[i] == 1) ++c, u = i;
    if (deg[i] > 2) return 0 * printf("-1");
  }
  if (c != 2) return 0 * printf("-1");
  for (int i = 1, v = u, p = 0, pa; p != v; ++i, p = pa) {
    path[i] = pa = v;
    if (go[v][0] != p && go[v][0])
      v = go[v][0];
    else if (go[v][1] != p && go[v][1])
      v = go[v][1];
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j)
      if (i != j) {
        a = i, b = j;
        cc[i][j] = cost[path[1]][i] + cost[path[2]][j];
        for (int k = 3; k <= n; ++k) {
          c = (3 - a - b) % 3;
          cc[i][j] += cost[path[k]][c];
          a = b, b = c;
        }
      }
  }
  long long min_cost = (long long)1e18;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      if (i != j)
        if (min_cost > cc[i][j]) a = i, b = j, min_cost = cc[i][j];
  color[path[1]] = a, color[path[2]] = b;
  for (int k = 3; k <= n; ++k) {
    c = (3 - a - b) % 3;
    color[path[k]] = c;
    a = b, b = c;
  }
  printf("%lld\n", min_cost);
  for (int i = 1; i <= n; ++i) printf("%d ", color[i] + 1);
}
