#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long arr[n][3];
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < n; j++) cin >> arr[j][i];
  }
  vector<long long> v[n];
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool pos = 1;
  long long ver = -1;
  unordered_map<long long, long long> cnt;
  for (long long i = 0; i < n; i++) {
    if (v[i].size() == 1) ver = i;
    cnt[v[i].size()]++;
  }
  if (!(cnt[1] == 2 && cnt[2] == n - 2)) {
    cout << -1;
    return 0;
  }
  vector<long long> hold;
  hold.push_back(ver);
  bool vis[n];
  memset(vis, 0, sizeof(vis));
  vis[ver] = 1;
  queue<long long> q;
  long long ans = LLONG_MAX;
  q.push(ver);
  while (q.size() > 0) {
    long long temp = q.front();
    q.pop();
    for (auto it = v[temp].begin(); it != v[temp].end(); it++) {
      if (vis[*it]) continue;
      vis[*it] = 1;
      hold.push_back(*it);
      q.push(*it);
    }
  }
  long long arr1[] = {0, 1, 2};
  long long ind1 = 0;
  long long st = 0;
  long long vali[6][n];
  memset(vali, 0, sizeof(vali));
  do {
    long long tempo = 0;
    for (long long j = 0; j < n; j++) tempo += arr[hold[j]][arr1[j % 3]];
    for (long long j = 0; j < n; j++) vali[st][hold[j]] = arr1[j % 3];
    ans = min(ans, tempo);
    if (ans == tempo) ind1 = st;
    st++;
  } while (next_permutation(arr1, arr1 + 3));
  cout << ans << "\n";
  for (long long j = 0; j < n; j++) cout << vali[ind1][j] + 1 << " ";
  return 0;
}
