#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<int> e[maxn];
int n;
long long v[maxn][4];
int ans[maxn], rec[maxn];
long long Min = 1000000000000000;
int p1 = -1, p2 = -1;
int in[maxn];
void dfs(int x, int fa, int fafa, long long w) {
  int k, kk;
  for (k = 1; k <= 3; k++) {
    if (k == rec[fa]) continue;
    if (-1 != fafa && k == rec[fafa]) continue;
    break;
  }
  rec[x] = k;
  if (x == p2) {
    if (w + v[p2][k] < Min) {
      Min = w + v[p2][k];
      for (int i = 1; i <= n; i++) ans[i] = rec[i];
    }
    return;
  }
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (y == fa) continue;
    dfs(y, x, fa, w + v[x][k]);
  }
  if (-1 == fafa) {
    for (k = k + 1; k <= 3; k++) {
      if (k == rec[fa]) continue;
      break;
    }
    kk = k;
    rec[x] = kk;
    for (int i = 0; i < e[x].size(); i++) {
      int y = e[x][i];
      if (y == fa) continue;
      dfs(y, x, fa, w + v[x][kk]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &v[i][1]);
  for (int i = 1; i <= n; i++) scanf("%lld", &v[i][2]);
  for (int i = 1; i <= n; i++) scanf("%lld", &v[i][3]);
  for (int i = 0, a, b; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    in[a]++;
    in[b]++;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int flag = true;
  for (int i = 1; i <= n; i++) {
    if (e[i].size() >= 3) {
      flag = false;
      break;
    }
  }
  if (!flag) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (1 == in[i] && -1 == p1)
      p1 = i;
    else if (1 == in[i])
      p2 = i;
  }
  for (int i = 1; i <= 3; i++) {
    rec[p1] = i;
    dfs(e[p1][0], p1, -1, v[p1][i]);
  }
  printf("%lld\n", Min);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
