#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 6;
const int N = 105;
const double eps = 1e-6;
long long qpow(long long x, long long y) {
  long long ans = 1;
  x %= mod;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
int n, rt, deg[maxn];
long long ans[maxn];
long long col[maxn][4], a[7];
vector<int> G[maxn];
pair<int, int> pp[7];
int id[maxn];
bool cmp(int x, int y) { return a[x] < a[y]; }
long long dfs(int u, int fa, int c, int cc, int dep) {
  ans[u] = c;
  long long ans = 0;
  for (int v : G[u])
    if (v != fa) {
      if (dep == 1)
        ans += col[v][cc] + dfs(v, u, cc, c, dep + 1);
      else {
        for (int j = 1; j <= 3; j++) {
          if (j == c || j == cc) continue;
          ans += col[v][j] + dfs(v, u, j, c, dep + 1);
        }
      }
    }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= n; j++) scanf("%lld", &col[j][i]);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    deg[u]++;
    deg[v]++;
    if (deg[u] >= 3 || deg[v] >= 3) {
      printf("-1\n");
      return 0;
    }
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] == 1) rt = i;
  }
  for (int i = 1; i <= 6; i++) id[i] = i;
  a[1] = dfs(rt, -1, 1, 2, 1) + col[rt][1];
  pp[1].first = 1;
  pp[1].second = 2;
  a[2] = dfs(rt, -1, 1, 3, 1) + col[rt][1];
  pp[2].first = 1;
  pp[2].second = 3;
  a[3] = dfs(rt, -1, 2, 1, 1) + col[rt][2];
  pp[3].first = 2;
  pp[3].second = 1;
  a[4] = dfs(rt, -1, 2, 3, 1) + col[rt][2];
  pp[4].first = 2;
  pp[4].second = 3;
  a[5] = dfs(rt, -1, 3, 1, 1) + col[rt][3];
  pp[5].first = 3;
  pp[5].second = 1;
  a[6] = dfs(rt, -1, 3, 2, 1) + col[rt][3];
  pp[6].first = 3;
  pp[6].second = 2;
  sort(id + 1, id + 1 + 6, cmp);
  printf("%lld\n", a[id[1]]);
  dfs(rt, -1, pp[id[1]].first, pp[id[1]].second, 1);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
