#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int n, u, v;
int cost[N][4];
vector<int> g[N];
int cc[N];
int col[N], vis[N];
long long res;
void dfs(int u, int f, int c) {
  col[u] = c;
  vis[u] = 1;
  res += cost[u][c];
  int siz = g[u].size();
  for (int i = 0; i < siz; i++) {
    int v = g[u][i];
    if (vis[v] || v == f) {
      continue;
    }
    dfs(v, u, 6 - col[u] - col[f]);
  }
}
int ind[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &cost[j][i]);
    }
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    ind[u]++;
    ind[v]++;
  }
  int fi = 1, se = g[1][0];
  long long ans = 1e18;
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (i == j) {
        continue;
      }
      res = 0;
      memset(vis, 0, sizeof(vis));
      col[fi] = i;
      col[se] = j;
      dfs(fi, se, i);
      dfs(se, fi, j);
      if (res < ans) {
        ans = res;
        for (int k = 1; k <= n; k++) {
          cc[k] = col[k];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ind[i] >= 3) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) {
    printf("%d%c", cc[i], i == n ? '\n' : ' ');
  }
  return 0;
}
