#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long cost[5][100005], b[100005];
vector<int> edge[100005], order;
void dfs(int u, int p = -1) {
  order.push_back(u);
  for (auto v : edge[u])
    if (v != p) dfs(v, u);
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> cost[0][i];
  for (int i = 1; i <= n; i++) cin >> cost[1][i];
  for (int i = 1; i <= n; i++) cin >> cost[2][i];
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  int root;
  for (int i = 1; i <= n; i++) {
    if (edge[i].size() >= 3) {
      cout << "-1" << endl;
      return 0;
    }
    if (edge[i].size() == 1) root = i;
  }
  dfs(root);
  vector<int> col = {0, 1, 2}, best;
  long long ans = 9000000000000000000;
  do {
    long long cur = 0LL;
    for (int i = 0; i < n; i++) {
      cur += cost[col[i % 3]][order[i]];
    }
    if (cur < ans) {
      ans = cur;
      best = col;
    }
  } while (next_permutation(col.begin(), col.end()));
  for (int i = 0; i < n; i++) b[order[i]] = best[i % 3];
  cout << ans << endl;
  for (int i = 1; i <= n; i++) cout << b[i] + 1 << " ";
  return 0;
}
