#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 1;
int n, C[3][M], ans[M];
vector<vector<int> > g;
long long Sum = 0;
vector<int> Per;
void DFS(int u, int p, int col) {
  col %= 3;
  ans[u] = Per[col] + 1;
  Sum += C[Per[col]][u];
  for (int v : g[u]) {
    if (v != p) {
      DFS(v, u, col + 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) scanf("%d", &C[i][j]);
  g.resize(n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int root = 0;
  for (int i = 0; i < n; i++) {
    if (g[i].size() > 2)
      return !printf("-1");
    else if (g[i].size() == 1)
      root = i;
  }
  Per = {0, 1, 2};
  long long Ans = 4e18;
  vector<int> best;
  do {
    Sum = 0;
    DFS(root, -1, 0);
    if (Ans > Sum) {
      Ans = Sum;
      best.clear();
      best.assign(ans, ans + n);
    }
  } while (next_permutation(Per.begin(), Per.end()));
  cout << Ans << endl;
  for (int u : best) printf("%d ", u);
}
