#include <bits/stdc++.h>
using namespace std;
const int64_t M1 = 998244353;
const int64_t M2 = 1000000007;
mt19937 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
vector<vector<int64_t>> a(3);
vector<int64_t> node[100001];
vector<int64_t> colour(3), actual_colour(3);
vector<int64_t> mark(100001);
int64_t dfs(int64_t u, int64_t p, int64_t ty) {
  int64_t sum = a[colour[ty]][u];
  for (int64_t v : node[u])
    if (v != p) sum += dfs(v, u, (ty + 1) % 3);
  return sum;
}
void dfs1(int64_t u, int64_t p, int64_t ty) {
  mark[u] = actual_colour[ty] + 1;
  for (int64_t v : node[u])
    if (v != p) dfs1(v, u, (ty + 1) % 3);
}
void solve() {
  int64_t n;
  cin >> n;
  for (int64_t i = 0; i < n; i++) node[i].clear();
  for (int64_t x = 0; x < 3; x++) {
    a[x].resize(n);
    for (int64_t &i : a[x]) cin >> i;
  }
  for (int64_t i = 1; i < n; i++) {
    int64_t u, v;
    cin >> u >> v;
    node[u - 1].push_back(v - 1);
    node[v - 1].push_back(u - 1);
  }
  int64_t root;
  for (int64_t i = 0; i < n; i++) {
    if ((int64_t)node[i].size() > 2) {
      cout << -1 << "\n";
      return;
    }
    if ((int64_t)node[i].size() == 1) root = i;
  }
  int64_t ans = M2 * M2;
  for (int64_t x = 0; x < 3; x++)
    for (int64_t y = 0; y < 3; y++) {
      if (x == y) continue;
      colour[0] = x;
      colour[1] = y;
      colour[2] = 3 - x - y;
      int64_t new_ans = dfs(root, -1, 0);
      if (new_ans < ans) {
        ans = new_ans;
        actual_colour = colour;
      }
    }
  cout << ans << "\n";
  dfs1(root, -1, 0);
  for (int64_t i = 0; i < n; i++) cout << mark[i] << " ";
  cout << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
