#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long dp[maxn];
struct E {
  int to, nxt;
  E(){};
  E(int to1, int nx1) {
    to = to1;
    nxt = nx1;
  }
} e[maxn * 2];
int head[maxn], tot = 0;
void adde(int u, int v) {
  tot++;
  e[tot] = E(v, head[u]);
  head[u] = tot;
}
long long cost[3][maxn];
long long ans = 1e17;
int out[maxn], color[maxn], en;
void dfs(int u, int fa, int ffa) {
  int cnt = 0;
  int ccc = 3 - color[fa] - color[ffa];
  color[u] = ccc;
  dp[u] = dp[fa] + cost[ccc][u];
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, u, fa);
    cnt++;
  }
  if (cnt == 0) {
    en = u;
    return;
  }
}
int d[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%I64d", &cost[i][j]);
    }
  }
  int t1, t2, mxd = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &t1, &t2);
    adde(t1, t2);
    adde(t2, t1);
    d[t1]++;
    d[t2]++;
    mxd = max(mxd, max(d[t1], d[t2]));
  }
  if (mxd > 2) {
    cout << -1 << endl;
    return 0;
  }
  int be;
  for (int i = 1; i <= n; i++) {
    if (d[i] == 1) {
      be = i;
      break;
    }
  }
  int sec;
  for (int i = head[be]; i; i = e[i].nxt) {
    if (e[i].to == be) continue;
    sec = e[i].to;
  }
  for (int i = 0; i < 3; i++) {
    color[be] = i;
    for (int j = 0; j < 3; j++) {
      if (i == j) continue;
      color[sec] = j;
      dp[sec] = cost[i][be] + cost[j][sec];
      for (int k = head[sec]; k; k = e[k].nxt) {
        if (e[k].to == be) continue;
        dfs(e[k].to, sec, be);
        if (ans > dp[en]) {
          ans = dp[en];
          for (int m = 1; m <= n; m++) {
            out[m] = color[m] + 1;
          }
        }
      }
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) printf("%d ", out[i]);
}
