#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const long long int INF = 1e16;
int n;
int cijena[3][MAXN];
vector<int> graf[MAXN];
vector<int> popis;
void dfs(int cvor, int prije) {
  popis.push_back(cvor);
  vector<int> novi;
  for (const auto &kamo : graf[cvor])
    if (kamo != prije) novi.push_back(kamo);
  if (novi.size() > 0 && novi.size() != 1) {
    printf("-1\n");
    exit(0);
  }
  if (!novi.empty()) dfs(novi[0], cvor);
}
int ispis[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (3); i++)
    for (int j = (0); j < (n); j++) scanf("%d", &cijena[i][j]);
  for (int i = (0); i < (n - 1); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    graf[a].push_back(b);
    graf[b].push_back(a);
  }
  int neki_list = -1;
  for (int i = (0); i < (n); i++)
    if (graf[i].size() == 1) {
      neki_list = i;
      break;
    }
  dfs(neki_list, -1);
  vector<int> perm = {0, 1, 2};
  long long int rj = INF;
  do {
    long long int sad = 0;
    for (int i = 0; i < n; i++) sad += cijena[perm[i % 3]][popis[i]];
    if (sad < rj) {
      rj = sad;
      for (int i = 0; i < n; i++) ispis[popis[i]] = perm[i % 3] + 1;
    }
  } while (next_permutation(perm.begin(), perm.end()));
  printf("%lld\n", rj);
  for (int i = (0); i < (n); i++) printf("%d ", ispis[i]);
  printf("\n");
  return 0;
}
