#include <bits/stdc++.h>
using namespace std;
int bugcnt;
const int maxn = 1e6 + 5;
int t, n;
int col[maxn], fcol[maxn];
vector<int> g[maxn];
long long c[maxn][3];
void dfs(int x, int par, int tmp) {
  col[x] = tmp;
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] == par) continue;
    dfs(g[x][i], x, (tmp + 1) % 3);
  }
}
void dfs2(int x, int par, int tmp) {
  col[x] = tmp;
  for (int i = 0; i < g[x].size(); i++) {
    if (g[x][i] == par) continue;
    dfs2(g[x][i], x, (tmp + 2) % 3);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i <= 2; i++)
    for (int j = 1; j <= n; j++) scanf("%I64d", &c[j][i]);
  int u, v;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int s = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i].size() > 2) {
      puts("-1");
      return 0;
    }
    if (g[i].size() == 1) s = i;
  }
  dfs(s, -1, 0);
  long long res = 0x7f7f7f7f7f7f7f7f, tmp;
  for (int i = 0; i <= 2; i++) {
    tmp = 0;
    for (int j = 1; j <= n; j++) tmp += c[j][(i + col[j]) % 3];
    if (tmp < res) {
      res = tmp;
      for (int j = 1; j <= n; j++) fcol[j] = (col[j] + i) % 3;
    }
  }
  dfs2(s, -1, 0);
  for (int i = 0; i <= 2; i++) {
    tmp = 0;
    for (int j = 1; j <= n; j++) tmp += c[j][(i + col[j]) % 3];
    if (tmp < res) {
      res = tmp;
      for (int j = 1; j <= n; j++) fcol[j] = (col[j] + i) % 3;
    }
  }
  cout << res << "\n";
  for (int i = 1; i <= n; i++) cout << fcol[i] + 1 << " ";
}
