#include <bits/stdc++.h>
using namespace std;
int cost[3][1 << 17];
int deg[1 << 17];
vector<int> g[1 << 17];
int p[3] = {0, 1, 2};
int color[1 << 17];
long long dfs(int u, int pa, int i = 0) {
  color[u] = p[i];
  long long ans = cost[color[u]][u];
  for (int v : g[u])
    if (v != pa) {
      ans += dfs(v, u, (i + 1) % 3);
    }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int c : {0, 1, 2})
    for (int i = 0; i < n; ++i) {
      cin >> cost[c][i];
    }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    ++deg[u], ++deg[v];
  }
  if (count_if(deg, deg + n, [](int v) { return v >= 3; })) {
    cout << -1 << '\n';
  } else {
    int v = find(deg, deg + n, 1) - deg;
    long long ans[6] = {};
    for (int _ = 0; _ < 6; ++_, next_permutation(p, p + 3)) {
      ans[_] = dfs(v, v);
    }
    int t = min_element(ans, ans + 6) - ans;
    for (int _ = 0; _ < 6; ++_, next_permutation(p, p + 3)) {
      if (t == _) {
        dfs(v, v);
        cout << ans[t] << '\n';
        for (int i = 0; i < n; ++i) cout << color[i] + 1 << " \n"[i == n - 1];
      }
    }
  }
}
