#include <bits/stdc++.h>
using namespace std;
long long n;
vector<vector<long long>> col, adj;
vector<long long> seq = {1, 2, 3};
set<pair<long long, vector<long long>>> st;
void dfs(long long root, long long prev, vector<long long> &cur_col,
         long long &tot, long long cnt = 0) {
  cur_col[root] = seq[cnt % 3];
  tot += col[seq[cnt % 3] - 1][root];
  for (auto x : adj[root]) {
    if (prev != x) {
      dfs(x, root, cur_col, tot, cnt + 1);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  col.resize(3, vector<long long>(n));
  adj.resize(n);
  for (long long i = 0; i < 3; ++i) {
    for (long long j = 0; j < n; ++j) {
      cin >> col[i][j];
    }
  }
  for (long long i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long root;
  for (long long i = 0; i < n; ++i) {
    if (adj[i].size() > 2) {
      cout << -1;
      return 0;
    }
    if (adj[i].size() == 1) {
      root = i;
    }
  }
  do {
    vector<long long> cur_col(n);
    long long tot = 0;
    dfs(root, -1, cur_col, tot);
    st.insert({tot, cur_col});
  } while (next_permutation(seq.begin(), seq.end()));
  auto it = st.begin();
  cout << it->first << '\n';
  for (auto x : it->second) {
    cout << x << ' ';
  }
}
