#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e16;
long long n, cost[5][100005], clo[100005], ans, deg[100005], rt, turn, tot;
long long ver[100005 << 1], nx[100005 << 1], fi[100005], cnt;
void add(long long x, long long y) {
  ver[++cnt] = y;
  nx[cnt] = fi[x];
  fi[x] = cnt;
}
void dfs(long long x, long long fa) {
  for (long long i = fi[x]; i; i = nx[i]) {
    long long y = ver[i];
    if (y == fa) continue;
    long long col = 6 - clo[x] - clo[fa];
    clo[y] = col;
    tot += cost[col][y];
    dfs(y, x);
  }
}
void work() {
  long long x = rt, y = ver[fi[x]];
  ans = inf;
  for (long long i = 1; i <= 3; i++)
    for (long long j = 1; j <= 3; j++)
      if (i != j) {
        clo[x] = i;
        clo[y] = j;
        tot = cost[i][x] + cost[j][y];
        dfs(y, x);
        if (ans > tot) {
          ans = tot;
          turn = i * 10 + j;
        }
      }
}
void print() {
  printf("%lld\n", ans);
  long long x = rt, y = ver[fi[x]];
  clo[x] = turn / 10;
  clo[y] = turn % 10;
  dfs(y, x);
  for (long long i = 1; i <= n; i++) printf("%lld ", clo[i]);
}
signed main() {
  scanf("%lld", &n);
  for (long long o = 1; o <= 3; o++)
    for (long long i = 1; i <= n; i++) scanf("%lld", &cost[o][i]);
  for (long long i = 1; i < n; i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    add(a, b);
    add(b, a);
    deg[a]++;
    deg[b]++;
  }
  for (long long i = 1; i <= n; i++)
    if (deg[i] > 2) {
      puts("-1");
      return 0;
    }
  for (long long i = 1; i <= n; i++)
    if (deg[i] == 1) {
      rt = i;
      break;
    }
  work();
  print();
  return 0;
}
