#include <bits/stdc++.h>
using namespace std;
const int ms = int(1e5) + 10;
int n;
int c[3][ms];
vector<int> adj[ms];
int a[ms], go[ms], pos = 0;
int isline() {
  int st = -1;
  for (int i = 0; i < n; i++) {
    if (adj[i].size() == 1)
      st = i;
    else if (adj[i].size() > 2)
      return -1;
  }
  return st;
}
void dfs(int u, int p = -1) {
  a[pos++] = u;
  for (auto v : adj[u])
    if (v != p) dfs(v, u);
}
long long test(long long c1, long long c2) {
  long long ans = c[c1][a[0]] + c[c2][a[1]];
  int c_at = 3 - c1 - c2;
  for (int i = 2; i < n; i++) {
    ans += c[c_at][a[i]];
    c1 = c2;
    c2 = c_at;
    c_at = 3 - c1 - c2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) cin >> c[i][j];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int st = isline();
  if (st == -1) {
    cout << -1 << endl;
    return 0;
  }
  dfs(st);
  long long ans_val = 1e18;
  int c1, c2;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      if (i != j) {
        long long k = test(i, j);
        if (ans_val > k) {
          ans_val = k, c1 = i, c2 = j;
        }
      }
    }
  cout << ans_val << endl;
  go[a[0]] = c1 + 1, go[a[1]] = c2 + 1;
  int c_at = 3 - c1 - c2;
  for (int i = 2; i < n; i++) {
    go[a[i]] = c_at + 1;
    c1 = c2;
    c2 = c_at;
    c_at = 3 - c1 - c2;
  }
  for (int i = 0; i < n; i++) cout << go[i] << " \n"[i + 1 == n];
  return 0;
}
