#include <bits/stdc++.h>
using namespace std;
const int maxn = 100009;
long long n, a[maxn], b[maxn], c[maxn], in[maxn], color[maxn];
void read(long long a[]) {
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
}
void over() {
  cout << -1;
  exit(0);
}
vector<int> vec[maxn];
void dfs(int now, int fa, int se1, int se2) {
  for (int i = 0; i < vec[now].size(); i++) {
    int v = vec[now][i];
    if (v == fa) continue;
    color[v] = 6 - se1 - se2;
    dfs(v, now, se2, color[v]);
  }
}
long long ans = 1e18;
long long isok(int i, int s) {
  if (s == 1)
    return a[i];
  else if (s == 2)
    return b[i];
  else
    return c[i];
}
void DP(int q, int w, int e) {
  long long temp = 0;
  for (int i = 1; i <= n; i++)
    if (color[i] == 1)
      temp += isok(i, q);
    else if (color[i] == 2)
      temp += isok(i, w);
    else
      temp += isok(i, e);
  ans = min(ans, temp);
}
void sovle(int q, int w, int e) {
  long long temp = 0;
  for (int i = 1; i <= n; i++)
    if (color[i] == 1)
      temp += isok(i, q);
    else if (color[i] == 2)
      temp += isok(i, w);
    else
      temp += isok(i, e);
  if (temp != ans) return;
  for (int i = 1; i <= n; i++)
    if (color[i] == 1)
      cout << q << " ";
    else if (color[i] == 2)
      cout << w << " ";
    else
      cout << e << " ";
  exit(0);
}
int main() {
  cin >> n;
  read(a), read(b), read(c);
  for (int i = 1; i < n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    in[l]++, in[r]++;
    vec[l].push_back(r);
    vec[r].push_back(l);
  }
  for (int i = 1; i <= n; i++)
    if (in[i] >= 3) over();
  int last;
  for (int i = 1; i <= n; i++)
    if (in[i] == 1) last = i;
  color[last] = 1, color[vec[last][0]] = 2;
  dfs(vec[last][0], last, 1, 2);
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) {
      if (j == i) continue;
      for (int q = 1; q <= 3; q++) {
        if (q == i || q == j) continue;
        DP(i, j, q);
      }
    }
  cout << ans << endl;
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) {
      if (j == i) continue;
      for (int q = 1; q <= 3; q++) {
        if (q == i || q == j) continue;
        sovle(i, j, q);
      }
    }
}
