#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000005;
const long long SQRTN = 1003;
const long long LOGN = 22;
const double PI = acos(-1);
const long long INF = 1e16;
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const double eps = 1e-9;
bool primes[100001];
long long spf[100001];
void sieve() {
  primes[0] = primes[1] = false;
  for (long long i = 1; i <= 100000; i++) {
    spf[i] = i;
    primes[i] = true;
  }
  spf[2] = 2;
  for (long long i = 4; i <= 100000; i += 2) {
    spf[i] = 2;
    primes[i] = false;
  }
  for (long long i = 3; i * i <= 100000; i += 2) {
    if (spf[i] == i) {
      for (long long j = i * i; j <= 100000; j += i) {
        if (spf[j] == j) spf[j] = i;
        primes[j] = false;
      }
    }
  }
  return;
}
long long power(long long n, long long m, long long p) {
  long long res = 1;
  n = n % MOD;
  while (m > 0) {
    if (m & 1) {
      res = ((res) % p * (n) % p) % p;
      m--;
    }
    n = ((n) % p * (n) % p) % p;
    m >>= 1;
  }
  return res;
}
long long N = 10000;
long long factorialNumInverse[100001];
long long naturalNumInverse[100001];
long long fact[100001];
void InverseofNumber(long long p) {
  naturalNumInverse[0] = naturalNumInverse[1] = 1;
  for (long long i = 2; i <= N; i++)
    naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p;
}
void InverseofFactorial(long long p) {
  factorialNumInverse[0] = factorialNumInverse[1] = 1;
  for (long long i = 2; i <= N; i++)
    factorialNumInverse[i] =
        (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p;
}
void factorial(long long p) {
  fact[0] = 1;
  for (long long i = 1; i <= N; i++) {
    fact[i] = (fact[i - 1] * i) % p;
  }
}
long long Binomial(long long N, long long R, long long p) {
  long long ans =
      ((fact[N] * factorialNumInverse[R]) % p * factorialNumInverse[N - R]) % p;
  return ans;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long nCrModPFermat(long long n, long long r, long long p) {
  if (n < r) return 0;
  if (r == 0) return 1;
  long long fac[n + 1];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void solvethetestcase();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  for (long long testcase = 1; testcase < t + 1; testcase++) {
    solvethetestcase();
  }
}
long long n, m, a, b, c, d, e, f, g, h, i, j, k, l, o, r, s, u, v, w, x, y, one,
    zero, p, t1, t2, t, q, cnt, val, res;
void bfs(long long node, vector<long long> adj[], vector<long long> &trav) {
  queue<long long> q;
  q.push(node);
  bool vis[n + 1];
  memset(vis, false, sizeof(vis));
  vis[node] = true;
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    trav.push_back(curr);
    for (auto it : adj[curr]) {
      if (!vis[it]) {
        q.push(it);
        vis[it] = true;
      }
    }
  }
  return;
}
void solvethetestcase() {
  cin >> n;
  long long cost[n + 1][4];
  memset(cost, 0, sizeof(cost));
  for (long long i = 0; i <= 2; i++) {
    for (long long j = 1; j <= n; j++) {
      cin >> cost[j][i];
    }
  }
  vector<long long> adj[n + 1];
  for (long long i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long ans = -1;
  bool foo = false;
  for (long long i = 1; i <= n; i++) {
    if (adj[i].size() == 1 && !foo) ans = i, foo = true;
    if (adj[i].size() > 2) {
      cout << -1;
      cout << "\n";
      return;
    }
  }
  vector<long long> trav;
  bfs(ans, adj, trav);
  long long lans = 1e18;
  vector<long long> perm = {0, 1, 2};
  do {
    long long ans1 = 0;
    for (long long i = 0; i < trav.size(); i++) {
      ans1 += (cost[trav[i]][perm[i % 3]]);
    }
    lans = min(lans, ans1);
  } while (next_permutation(perm.begin(), perm.end()));
  cout << lans << "\n";
  long long fans[n + 1];
  memset(fans, 0, sizeof(fans));
  do {
    long long ans1 = 0;
    for (long long i = 0; i < trav.size(); i++) {
      ans1 += (cost[trav[i]][perm[i % 3]]);
    }
    if (ans1 == lans) {
      for (long long i = 0; i < n; i++) fans[trav[i]] = perm[i % 3];
      for (long long i = 1; i <= n; i++) cout << fans[i] + 1 << " ";
      return;
    }
  } while (next_permutation(perm.begin(), perm.end()));
}
