#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long N = 1e5 + 5;
long long col[3][N];
vector<long long> adj[N];
long long cur;
void dfs(long long node, long long col_node, long long par, long long col_par,
         vector<long long> &temp) {
  long long c;
  for (long long i = 0; i < 3; i++) {
    if (i != col_node && i != col_par) c = i;
  }
  for (auto i : adj[node]) {
    if (i != par) {
      temp[i] = c;
      cur += col[c][i];
      dfs(i, c, node, col_node, temp);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> col[0][i];
  for (long long i = 1; i <= n; i++) cin >> col[1][i];
  for (long long i = 1; i <= n; i++) cin >> col[2][i];
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long root = -1;
  for (long long i = 1; i <= n; i++) {
    if ((long long)adj[i].size() > 2) {
      cout << "-1\n";
      return;
    }
    if ((long long)adj[i].size() == 1) root = i;
  }
  vector<pair<long long, long long> > poss{{0, 1}, {1, 0}, {1, 2},
                                           {2, 1}, {0, 2}, {2, 0}};
  long long ans = (long long)2e18;
  vector<long long> gg;
  for (auto i : poss) {
    vector<long long> temp(n + 1, 0);
    long long col_root = i.first, col_next = i.second;
    cur = 0;
    cur += col[col_root][root];
    cur += col[col_next][adj[root][0]];
    temp[root] = col_root;
    temp[adj[root][0]] = col_next;
    dfs(adj[root][0], col_next, root, col_root, temp);
    if (cur < ans) {
      ans = cur;
      gg.clear();
      gg = temp;
    }
  }
  cout << ans << "\n";
  for (long long i = 1; i <= n; i++) cout << gg[i] + 1 << " ";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
