#include <bits/stdc++.h>
using namespace std;
constexpr const int maxn = 1 << 17;
vector<int> adj[maxn];
int c[maxn][4], vis[maxn], col[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  for (int i : {1, 2, 3})
    for (int u = 1; u <= n; ++u) cin >> c[u][i];
  for (int i = 1; i != n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int u = 1; u <= n; ++u)
    if (int(adj[u].size()) > 2) return cout << -1 << endl, 0;
  int l = 0;
  for (int u = 1; u <= n; ++u)
    if (int(adj[u].size()) < 2) l = u;
  vis[l] = 1;
  vector<int> line(1, l);
  while (int(line.size()) != n)
    for (int u : adj[line.back()])
      if (!vis[u]) {
        line.push_back(u);
        vis[u] = 1;
        break;
      }
  vector<int> p = {1, 2, 3};
  vector<pair<long long, vector<int>>> dps;
  do {
    long long dp = 0;
    for (int i = 0; i != n; ++i) dp += c[line[i]][p[i % 3]];
    dps.emplace_back(dp, p);
  } while (next_permutation(p.begin(), p.end()));
  auto res = *min_element(dps.begin(), dps.end());
  cout << res.first << endl;
  for (int i = 0; i != n; ++i) col[line[i]] = res.second[i % 3];
  for (int u = 1; u <= n; ++u) cout << col[u] << " \n"[u == n];
}
