#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const long long LLINF = 9223372036854775807;
const int M = 1000000007;
const int HM = 2147483647;
const int HP = 43;
const double EPS = 1e-12;
vector<vector<long long> > g(100000);
int g_st(int v, int prev) {
  if (g[v].size() == 1) return v;
  if (prev != g[v][0])
    return g_st(g[v][0], v);
  else
    return g_st(g[v][1], v);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  vector<vector<long long> > cost(n, vector<long long>(3));
  for (int i = 0; i < n; i++) cin >> cost[i][0];
  for (int i = 0; i < n; i++) cin >> cost[i][1];
  for (int i = 0; i < n; i++) cin >> cost[i][2];
  long long t1, t2;
  for (int i = 0; i < n - 1; i++) {
    cin >> t1 >> t2;
    --t1;
    --t2;
    g[t1].push_back(t2);
    g[t2].push_back(t1);
  }
  bool ok = true;
  for (auto v : g) {
    if (v.size() > 2) {
      ok = false;
      break;
    }
  }
  if (ok) {
    vector<int> perm = {0, 1, 2};
    long long ans = LLINF;
    vector<int> res(n);
    int start = g_st(0, -1);
    do {
      long long curr = cost[start][perm[0]];
      int prev = start, v = g[start][0];
      for (int i = 1; i < n; i++) {
        curr += cost[v][perm[i % 3]];
        if (prev != g[v][0]) {
          prev = v;
          v = g[v][0];
        } else if (g[v].size() != 1) {
          prev = v;
          v = g[v][1];
        }
      }
      if (curr < ans) {
        ans = curr;
        prev = start;
        v = g[start][0];
        res[start] = perm[0] + 1;
        for (int i = 1; i < n; i++) {
          res[v] = perm[i % 3] + 1;
          if (prev != g[v][0]) {
            prev = v;
            v = g[v][0];
          } else if (g[v].size() != 1) {
            prev = v;
            v = g[v][1];
          }
        }
      }
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
    for (auto x : res) cout << x << ' ';
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
