#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long inf = 1e18;
long long a[maxn][5], ans[maxn];
vector<int> p[maxn];
int cnt[10][3] = {{1, 2, 3}, {2, 1, 3}, {3, 1, 2},
                  {1, 3, 2}, {2, 3, 1}, {3, 2, 1}};
long long dfs(int x, int fa, int w, int t) {
  long long ans = a[x][cnt[w][t]];
  for (int i = 0; i < p[x].size(); i++) {
    int y = p[x][i];
    if (y == fa) continue;
    ans += dfs(y, x, w, (t + 1) % 3);
  }
  return ans;
}
void dfs1(int x, int fa, int w, int t) {
  ans[x] = cnt[w][t];
  for (int i = 0; i < p[x].size(); i++) {
    int y = p[x][i];
    if (y == fa) continue;
    dfs1(y, x, w, (t + 1) % 3);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int j = 1; j <= 3; j++)
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i][j]);
  int f = 0, root = 1;
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    p[x].push_back(y);
    p[y].push_back(x);
    if (p[x].size() > 2 || p[y].size() > 2) f = 1;
  }
  for (int i = 1; i <= n; i++)
    if (p[i].size() == 1) root = i;
  if (f == 1)
    printf("-1\n");
  else {
    long long Min = inf, ansi = 0;
    for (int i = 0; i < 6; i++) {
      long long t = dfs(root, 0, i, 0);
      if (Min > t) Min = t, ansi = i;
    }
    printf("%lld\n", Min);
    dfs1(root, 0, ansi, 0);
    for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  }
}
