#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
    __attribute__((warn_unused_result));
int const maxn = 100005;
vector<int> gr[maxn];
int c[maxn][3];
pair<int, int> dfs(int v, int p = -1) {
  pair<int, int> res = {0, v};
  for (int ne : gr[v])
    if (ne != p) {
      auto cur = dfs(ne, v);
      if (cur.first >= res.first) res = {cur.first + 1, cur.second};
    }
  return res;
}
vector<int> order;
void mord(int v, int p = -1) {
  order.push_back(v);
  for (int ne : gr[v])
    if (ne != p) mord(ne, v);
}
int col[maxn];
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int j = 0; j < 3; ++j)
    for (int i = 0; i < n; ++i) cin >> c[i][j];
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  auto mdist = dfs(1);
  mdist = dfs(mdist.second);
  if (mdist.first + 1 != n) {
    cout << (-1) << '\n';
    exit(0);
  };
  mord(mdist.second);
  long long ans = 1000000000000000000;
  pair<int, int> be;
  for (int f = 0; f < 3; ++f)
    for (int s = 0; s < 3; ++s)
      if (f != s) {
        int lf = f;
        int ls = s;
        long long cur = 0;
        for (int i = 0; i < n; ++i) {
          int ne = 3 - ls - lf;
          cur += c[order[i]][lf];
          lf = ls;
          ls = ne;
        }
        if (ans > cur) {
          be = {f, s};
          ans = cur;
        }
      }
  cout << ans << endl;
  int lf = be.first;
  int ls = be.second;
  for (int i = 0; i < n; ++i) {
    col[order[i]] = lf + 1;
    int ne = 3 - ls - lf;
    lf = ls;
    ls = ne;
  }
  for (int i = 0; i < n; ++i) cout << col[i] << " \n"[i == n - 1];
}
