#include <bits/stdc++.h>
using namespace std;
const float pi = acos(-1.0);
const int maxn = 1e5 + 5;
int c[maxn];
long long a[5][maxn], b[maxn];
vector<int> vec[maxn];
void dfs(int u, int fa) {
  for (auto p : vec[u]) {
    if (p != fa) {
      c[p] = 6 - c[u] - c[fa];
      dfs(p, u);
    }
  }
}
int main() {
  int u, v;
  int t, n;
  cin >> n;
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  int fu, fv;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  int cnt = 0, cnt1 = 0;
  for (int i = 1; i <= n; i++) {
    if (vec[i].size() == 2) {
      cnt++;
    }
    if (vec[i].size() == 1) {
      fv = i;
      cnt1++;
    }
  }
  if (cnt != n - 2 && cnt1 != 2) {
    puts("-1");
    return 0;
  }
  long long res = 1e17, ans = 0;
  ;
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (i == j) continue;
      fu = vec[fv][0];
      c[fu] = i, c[fv] = j;
      dfs(fu, fv);
      ans = 0;
      for (int k = 1; k <= n; k++) ans += a[c[k]][k];
      if (ans < res) {
        res = ans;
        for (int k = 1; k <= n; k++) {
          b[k] = c[k];
        }
      }
    }
  }
  printf("%lld\n", res);
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  cout << endl;
}
