#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007;
const double pi = 3.1415926535897932, eps = 1e-6;
int n, c[4][100005], deg[100005], p[5] = {1, 2, 3}, col[100005];
vector<int> v[100005];
vector<int> ord, cur, ans;
void dfs(int x, int fa) {
  ord.push_back(x);
  for (int(i) = (0); (i) < (v[x].size()); (i)++) {
    if (v[x][i] == fa) continue;
    dfs(v[x][i], x);
  }
}
long long check(int x) {
  long long res = 0;
  for (int(i) = (0); (i) <= (2); (i)++)
    col[i] = p[i], res += c[col[i]][ord[i]], cur[ord[i]] = col[i];
  for (int(i) = (3); (i) < (n); (i)++) {
    for (int(j) = (1); (j) <= (3); (j)++)
      if (j != col[i - 1] && j != col[i - 2])
        col[i] = j, res += c[j][ord[i]], cur[ord[i]] = col[i];
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int(j) = (1); (j) <= (3); (j)++)
    for (int(i) = (1); (i) <= (n); (i)++) scanf("%d", &c[j][i]);
  for (int(i) = (1); (i) < (n); (i)++) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    v[t1].push_back(t2);
    v[t2].push_back(t1);
    deg[t1]++;
    deg[t2]++;
  }
  for (int(i) = (1); (i) <= (n); (i)++)
    if (deg[i] > 2) {
      puts("-1");
      return 0;
    }
  cur.resize(n + 2);
  ans.resize(n + 2);
  int id = 0;
  for (int(i) = (1); (i) <= (n); (i)++)
    if (deg[i] == 1) {
      id = i;
      break;
    }
  dfs(id, 0);
  long long an = 1e18;
  do {
    long long cost = check(1);
    if (an > cost) an = cost, ans = cur;
  } while (next_permutation(p, p + 3));
  printf("%lld\n", an);
  for (int(i) = (1); (i) <= (n); (i)++) printf("%d ", ans[i]);
  return 0;
}
