#include <bits/stdc++.h>
using namespace std;
void run();
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  run();
  return 0;
}
long long n;
const long long inf = 1e18;
const long long maxn = 1e5 + 1;
vector<long long> graph[maxn];
long long color[3][maxn];
long long dp[maxn][3][3];
bool kek = false;
long long print[maxn];
void dfs(long long v, long long p = -1) {
  if (graph[v].size() > 2) kek = true;
  bool flag = true;
  vector<vector<long long>> sum(3, vector<long long>(3));
  for (auto &u : graph[v]) {
    if (u == p) continue;
    flag = false;
    dfs(u, v);
    for (long long c0 = 0; c0 < 3; c0++) {
      for (long long c1 = 0; c1 < 3; c1++) {
        if (c0 == c1) continue;
        sum[c0][c1] += dp[u][c0][c1];
      }
    }
  }
  if (flag) {
    for (long long c0 = 0; c0 < 3; c0++) {
      for (long long c1 = 0; c1 < 3; c1++) {
        if (c1 == c0) continue;
        dp[v][c0][c1] = color[c0][v];
      }
    }
  } else {
    for (long long c0 = 0; c0 < 3; c0++) {
      for (long long c1 = 0; c1 < 3; c1++) {
        if (c0 == c1) continue;
        auto c2 = 3 - c0 - c1;
        dp[v][c0][c1] = min(dp[v][c0][c1], sum[c1][c2] + color[c0][v]);
      }
    }
  }
}
void get_ans(long long v, long long c0, long long c1, long long p) {
  print[v] = c0;
  for (auto &u : graph[v]) {
    if (u == p) continue;
    long long c2 = 3 - c0 - c1;
    get_ans(u, c1, c2, v);
  }
}
void run() {
  cin >> n;
  for (auto &c : color) {
    for (long long i = 0; i < n; i++) {
      cin >> c[i];
    }
  }
  for (auto &i : dp) {
    for (auto &c1 : i) {
      for (long long &c2 : c1) {
        c2 = inf;
      }
    }
  }
  long long root = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (long long i = 0; i < n; i++) {
    if (graph[i].size() == 1) root = i;
  }
  dfs(root);
  long long ans = inf;
  pair<long long, long long> lol;
  for (long long c1 = 0; c1 < 3; c1++) {
    for (long long c2 = 0; c2 < 3; c2++) {
      if (c1 == c2) continue;
      if (dp[root][c1][c2] < ans) {
        ans = min(ans, dp[root][c1][c2]);
        lol = make_pair(c1, c2);
      }
    }
  }
  if (kek) {
    ans = -1;
    cout << ans;
    return;
  }
  cout << ans << '\n';
  get_ans(root, lol.first, lol.second, -1);
  for (long long i = 0; i < n; i++) cout << print[i] + 1 << " ";
}
