#include <bits/stdc++.h>
using namespace std;
long long ans, cur, aft, u, v, dp[5][5][300005], par[300005], c[300005][5], n,
    i, k, col[300005];
vector<long long> V[300005];
queue<long long> q;
void bfs() {
  q.push(u);
  while (q.size() != 0) {
    u = q.front();
    v = u;
    q.pop();
    dp[1][2][u] = dp[2][3][par[u]] + c[u][1];
    dp[1][3][u] = dp[3][2][par[u]] + c[u][1];
    dp[2][3][u] = dp[3][1][par[u]] + c[u][2];
    dp[2][1][u] = dp[1][3][par[u]] + c[u][2];
    dp[3][2][u] = dp[2][1][par[u]] + c[u][3];
    dp[3][1][u] = dp[1][2][par[u]] + c[u][3];
    for (i = 0; i < V[u].size(); i++) {
      if (par[u] != V[u][i]) {
        q.push(V[u][i]);
        par[V[u][i]] = u;
      }
    }
  }
}
int main() {
  cin >> n;
  for (i = 1; i <= 3; i++)
    for (k = 1; k <= n; k++) cin >> c[k][i];
  for (i = 2; i <= n; i++) {
    cin >> u >> v;
    V[u].push_back(v);
    V[v].push_back(u);
  }
  for (k = 1; k <= n; k++) {
    if (V[k].size() == 3) {
      cout << -1;
      return 0;
    }
    if (V[k].size() == 1) u = k;
  }
  bfs();
  ans = 1e17;
  for (k = 1; k <= 3; k++)
    for (i = 1; i <= 3; i++)
      if (i != k)
        if (dp[k][i][v] < ans) ans = dp[k][i][v], cur = k, aft = i;
  col[v] = cur;
  col[par[v]] = aft;
  v = par[par[v]];
  int r = 2;
  while (v != 0) {
    col[v] = 6 - cur - aft;
    cur = aft;
    aft = col[v];
    v = par[v];
    r++;
  }
  cout << ans << endl;
  for (k = 1; k <= n; k++) cout << col[k] << " ";
}
