#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
vector<ll> ad[100005], vv;
ll color1[100005], color2[100005], color3[100005], deg[100005],
    dp[100005][4][4], n;
ll ans_ara[100005], dir[100005][4][4];
void dfs(ll src, ll pre) {
  vv.push_back(src);
  for (ll v : ad[src]) {
    if (v == pre) continue;
    dfs(v, src);
  }
}
ll func(ll indx, ll pre, ll preOfpre) {
  if (indx == n) {
    return 0;
  }
  if (dp[indx][pre][preOfpre] != -1) {
    return dp[indx][pre][preOfpre];
  }
  ll ans = 1e18, cost;
  for (ll i = 1; i <= 3; i++) {
    if (i != pre && i != preOfpre) {
      if (i == 1)
        cost = color1[vv[indx]];
      else if (i == 2)
        cost = color2[vv[indx]];
      else
        cost = color3[vv[indx]];
      ll temp = cost + func(indx + 1, i, pre);
      if (temp < ans) {
        ans = temp;
        dir[indx][pre][preOfpre] = i;
      }
    }
  }
  return dp[indx][pre][preOfpre] = ans;
}
void go(ll indx, ll pre, ll preOfpre) {
  if (indx == n) {
    return;
  }
  ans_ara[vv[indx]] = dir[indx][pre][preOfpre];
  go(indx + 1, dir[indx][pre][preOfpre], pre);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll i, j, leaf;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> color1[i];
  for (i = 1; i <= n; i++) cin >> color2[i];
  for (i = 1; i <= n; i++) cin >> color3[i];
  bool flag = true;
  for (i = 1; i <= n - 1; i++) {
    ll u, v;
    cin >> u >> v;
    ad[u].push_back(v);
    ad[v].push_back(u);
    deg[u]++;
    deg[v]++;
    if (deg[u] > 2 || deg[v] > 2) flag = false;
  }
  if (!flag) {
    cout << "-1" << endl;
    return 0;
  }
  memset(dp, -1, sizeof dp);
  for (i = 1; i <= n; i++) {
    if (deg[i] == 1) {
      leaf = i;
      break;
    }
  }
  dfs(leaf, 0);
  ll ans = func(0, 0, 0);
  cout << ans << endl;
  go(0, 0, 0);
  for (i = 1; i <= n; i++) {
    cout << ans_ara[i] << ' ';
  }
  cout << endl;
  return 0;
}
