#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const long long int mod = 1000000007;
const long long int INF64 = mod * mod + 1;
void solve() {
  long long int n;
  cin >> n;
  vector<vector<long long int>> c(n + 1, vector<long long int>(3, 0));
  for (long long int j = 0; j < 3; j++) {
    for (long long int i = 1; i <= n; i++) cin >> c[i][j];
  }
  vector<long long int> adj[n + 1];
  for (long long int i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long int root;
  for (long long int i = 1; i <= n; i++) {
    if (adj[i].size() > 2) {
      cout << -1 << '\n';
      return;
    }
    if (adj[i].size() == 1) root = i;
  }
  vector<long long int> v;
  function<void(long long int, long long int)> dfs = [&](long long int i,
                                                         long long int p) {
    v.push_back(i);
    if (adj[i][0] != p)
      dfs(adj[i][0], i);
    else if (adj[i].size() == 2)
      dfs(adj[i][1], i);
  };
  dfs(root, 0);
  long long int ans;
  vector<long long int> yo;
  vector<long long int> color(n);
  color[0] = 0, color[1] = 1;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  long long int curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  ans = curr;
  yo = color;
  color[0] = 0, color[1] = 2;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  if (ans > curr) {
    ans = curr;
    yo = color;
  }
  color[0] = 1, color[1] = 0;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  if (ans > curr) {
    ans = curr;
    yo = color;
  }
  color[0] = 1, color[1] = 2;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  if (ans > curr) {
    ans = curr;
    yo = color;
  }
  color[0] = 2, color[1] = 1;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  if (ans > curr) {
    ans = curr;
    yo = color;
  }
  color[0] = 2, color[1] = 0;
  for (long long int i = 2; i < n; i++)
    color[i] = 3 - color[i - 1] - color[i - 2];
  curr = 0;
  for (long long int i = 0; i < n; i++) curr += c[v[i]][color[i]];
  if (ans > curr) {
    ans = curr;
    yo = color;
  }
  cout << ans << '\n';
  vector<long long int> req(n + 1);
  for (long long int i = 1; i <= n; i++) req[v[i - 1]] = yo[i - 1] + 1;
  for (long long int i = 1; i <= n; i++) cout << req[i] << " ";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  for (long long int i = 1; i <= T; i++) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
}
