#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
vector<int> edge[N];
int a[3][N], in[N], colour[N];
long long dp[3][3][N], inf = 1e17;
void solve(int fa, int root) {
  int v = root, l;
  for (int i = 0; i < edge[fa].size(); ++i) {
    l = edge[fa][i];
    if (l == root) continue;
    v = l;
    solve(l, fa);
  }
  if (v == root) {
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j) dp[i][j][fa] = a[j][fa] * 1LL;
  } else {
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j) {
        if (i == j) continue;
        dp[i][j][fa] = dp[3 - i - j][i][v] + a[j][fa];
      }
  }
}
void print(long long sum, int pre, int now, int fa, int root) {
  colour[fa] = now;
  int v = root;
  for (int i = 0; i < edge[fa].size(); ++i)
    if (edge[fa][i] != root) {
      v = edge[fa][i];
      break;
    }
  if (v != root) {
    print(dp[3 - now - pre][pre][v], 3 - now - pre, pre, v, fa);
  }
  return;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    int u, v;
    for (int i = 0; i < 3; ++i)
      for (int j = 1; j < n + 1; ++j) scanf("%d", &a[i][j]);
    for (int i = 0; i < n + 1; ++i) edge[i].clear(), in[i] = 0;
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j)
        for (int k = 1; k < n + 1; ++k) dp[i][j][k] = inf;
    int ok = 1;
    for (int i = 0; i < n - 1; ++i) {
      scanf("%d %d", &u, &v);
      edge[u].push_back(v);
      edge[v].push_back(u);
      in[u] += 1;
      in[v] += 1;
      if (in[u] > 2 || in[v] > 2) ok = 0;
    }
    int root = -1;
    for (int i = 0; i < n + 1; ++i)
      if (in[i] == 1) root = i;
    if (!ok || root == -1) {
      puts("-1");
      continue;
    }
    solve(root, -1);
    long long ans = inf;
    int pre, now;
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j) {
        if (ans > dp[i][j][root]) ans = dp[i][j][root], now = j, pre = i;
      }
    printf("%lld\n", ans);
    print(ans, pre, now, root, root);
    for (int i = 1; i < n + 1; ++i) cout << colour[i] + 1 << " ";
    cout << endl;
  }
  return 0;
}
