#include <bits/stdc++.h>
using namespace std;
const long long MN = 1e5 + 7;
long long a[MN][3], mark[MN], n, dp[6];
vector<long long> g[MN], v;
void dfs(long long now, long long dis) {
  v.push_back(now);
  mark[now] = 1;
  for (long long j = 0; j < 3; j++) {
    dp[j] += a[now][(dis + j) % 3];
  }
  for (long long j = 0; j < 3; j++) {
    dp[j + 3] += a[now][(j - dis + 14348907) % 3];
  }
  for (long long i = 0; i < g[now].size(); i++) {
    if (!mark[g[now][i]]) {
      dfs(g[now][i], dis + 1);
    }
  }
}
signed main() {
  long long x = 1;
  for (long long i = 0; i < 15; i++) {
    x *= 3;
  }
  cin >> n;
  for (long long j = 0; j < 3; j++) {
    for (long long i = 0; i < n; i++) {
      cin >> a[i][j];
    }
  }
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    if (g[i].size() > 2) {
      cout << -1;
      return 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (g[i].size() == 1) {
      dfs(i, 0);
      break;
    }
  }
  long long mini =
      min(dp[0], min(dp[1], min(dp[2], min(dp[3], min(dp[4], dp[5])))));
  cout << mini << endl;
  for (long long j = 0; j < 3; j++) {
    if (dp[j] != mini) continue;
    long long ans[MN];
    for (long long i = 0; i < n; i++) {
      ans[v[i]] = (i + j) % 3 + 1;
    }
    for (long long i = 0; i < n; i++) {
      cout << ans[i] << ' ';
    }
    return 0;
  }
  for (long long j = 0; j < 3; j++) {
    if (dp[j + 3] != mini) continue;
    long long ans[MN];
    for (long long i = 0; i < n; i++) {
      ans[v[i]] = (j - i + 14348907) % 3 + 1;
    }
    for (long long i = 0; i < n; i++) {
      cout << ans[i] << ' ';
    }
    return 0;
  }
}
