#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long ret = 0, flag = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') ret = ret * 10 + (c ^ '0'), c = getchar();
  return flag * ret;
}
const long long N = 1e5 + 5;
long long n, ans;
long long cost[N][4];
vector<long long> edge[N];
long long col[N], COL[N];
void vis(long long x, long long dad, long long col1, long long col2) {
  ans += cost[x][col[x] = 6 - col1 - col2];
  if (edge[x].size() > 1)
    vis(edge[x][0] == dad ? edge[x][1] : edge[x][0], x, col2, 6 - col1 - col2);
}
int main() {
  n = read();
  for (long long i = 1; i <= 3; i++) {
    for (long long j = 1; j <= n; j++) cost[j][i] = read();
  }
  if (n == 1) {
    int t1 = cost[1][1], t2 = cost[1][2], t3 = cost[1][3];
    if (t1 <= t2 && t1 <= t3)
      printf("%lld\n%lld", t1, t1);
    else if (t2 <= t1 && t2 <= t3)
      printf("%lld\n%lld", t2, t2);
    else
      printf("%lld\n%lld", t3, t3);
    return 0;
  }
  for (long long i = 1; i < n; i++) {
    long long u = read(), v = read();
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  long long x, y;
  for (long long i = 1; i <= n; i++) {
    if (edge[i].size() == 1)
      x = i, y = edge[i][0];
    else if (edge[i].size() >= 3) {
      printf("-1");
      return 0;
    }
  }
  long long tmp = 123456789987654321ll;
  for (long long i = 1; i <= 3; i++) {
    for (long long j = 1; j <= 3; j++) {
      if (i == j) continue;
      ans = cost[x][i] + cost[y][j];
      col[x] = i, col[y] = j;
      if (edge[y].size() > 1)
        vis(edge[y][0] == x ? edge[y][1] : edge[y][0], y, i, j);
      if (ans < tmp) {
        tmp = ans;
        copy(col + 1, col + n + 1, COL + 1);
      }
    }
  }
  printf("%lld\n", tmp);
  for (long long i = 1; i <= n; i++) printf("%lld ", COL[i]);
  return 0;
}
