#include <bits/stdc++.h>
using namespace std;
const int64_t N = 1e5 + 10, inf = 1e18;
int64_t n, c[3][N], col[N], sum[3];
int64_t MOL[3], ans = inf, ANS[3];
vector<int64_t> mol[3], adj[N];
void dfs(int64_t v, int64_t p, int64_t c) {
  mol[c].push_back(v);
  col[v] = c;
  for (int64_t i = 0; i < adj[v].size(); i++) {
    if (adj[v][i] == p) {
      continue;
    }
    dfs(adj[v][i], v, (c + 1) % 3);
  }
}
void hes() {
  for (int64_t i = 0; i < 3; i++) {
    sum[i] = 0;
    for (int64_t j = 0; j < mol[i].size(); j++) {
      sum[i] += c[MOL[i]][mol[i][j]];
    }
  }
  if (sum[0] + sum[1] + sum[2] < ans) {
    ANS[0] = MOL[0];
    ANS[1] = MOL[1];
    ANS[2] = MOL[2];
    ans = sum[0] + sum[1] + sum[2];
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int64_t i = 1; i <= n; i++) {
    cin >> c[0][i];
  }
  for (int64_t i = 1; i <= n; i++) {
    cin >> c[1][i];
  }
  for (int64_t i = 1; i <= n; i++) {
    cin >> c[2][i];
  }
  int64_t x, y;
  for (int64_t i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    if (adj[x].size() > 2 || adj[y].size() > 2) {
      cout << -1;
      return 0;
    }
  }
  int64_t st = 1;
  for (int64_t i = 1; i <= n; i++) {
    if (adj[i].size() == 1) {
      st = i;
      break;
    }
  }
  dfs(st, st, 0);
  MOL[0] = 0;
  MOL[1] = 1;
  MOL[2] = 2;
  hes();
  MOL[0] = 0;
  MOL[1] = 2;
  MOL[2] = 1;
  hes();
  MOL[0] = 1;
  MOL[1] = 0;
  MOL[2] = 2;
  hes();
  MOL[0] = 1;
  MOL[1] = 2;
  MOL[2] = 0;
  hes();
  MOL[0] = 2;
  MOL[1] = 0;
  MOL[2] = 1;
  hes();
  MOL[0] = 2;
  MOL[1] = 1;
  MOL[2] = 0;
  hes();
  cout << ans << '\n';
  for (int64_t i = 1; i <= n; i++) {
    cout << int32_t(ANS[col[i]] + 1) << ' ';
  }
}
