#include <bits/stdc++.h>
using namespace std;
const long long inf = LLONG_MAX;
const long long mod = 1000000007;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long modexp(long long x, long long y, long long mod) {
  if (y == 0) return 1;
  long long z = modexp(x, y / 2, mod);
  z = (z * z) % mod;
  if (y % 2) z = (z * x) % mod;
  return z;
}
void dfs(long long v, long long p, vector<vector<long long> > &adj,
         vector<long long> &vis) {
  vis.push_back(v);
  for (auto u : adj[v]) {
    if (u != p) {
      dfs(u, v, adj, vis);
    }
  }
}
void solve() {
  long long n;
  cin >> n;
  vector<vector<long long> > c(n, vector<long long>(3));
  for (long long j = (0); j < (3); j++) {
    for (long long i = (0); i < (n); i++) {
      cin >> c[i][j];
    }
  }
  vector<vector<long long> > adj(n);
  for (long long i = (0); i < (n - 1); i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long ok = 0, start;
  for (long long i = (0); i < (n); i++) {
    if (adj[i].size() > 2) ok = 1;
    if (adj[i].size() == 1) start = i;
  }
  if (ok) {
    cout << -1 << endl;
    return;
  }
  vector<long long> vis;
  dfs(start, -1, adj, vis);
  vector<long long> num(3);
  for (long long i = (0); i < (3); i++) num[i] = i;
  long long ans = inf, sum;
  vector<long long> res(n), cur(n);
  do {
    sum = 0;
    for (long long i = (0); i < (n); i++) {
      cur[i] = num[i % 3];
      sum += c[vis[i]][cur[i]];
    }
    if (ans > sum) {
      ans = sum;
      for (long long i = (0); i < (n); i++) res[vis[i]] = cur[i] + 1;
    }
  } while (next_permutation(num.begin(), num.end()));
  cout << ans << endl;
  for (long long i = (0); i < (n); i++) {
    cout << res[i] << " ";
  }
  cout << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
