#include <bits/stdc++.h>
using namespace std;
void dfs(long long int x, vector<long long int> &path, vector<bool> &vis,
         vector<vector<long long int>> &g) {
  if (vis[x]) return;
  vis[x] = true;
  path.push_back(x);
  for (long long int y : g[x]) {
    if (!vis[y]) dfs(y, path, vis, g);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<vector<long long int>> cost(3, vector<long long int>(n + 1, 0));
  for (long long int i = 0; i < 3; i++)
    for (long long int j = 0; j < n; j++) cin >> cost[i][j];
  vector<vector<long long int>> g(n + 1);
  for (long long int i = 0; i < n - 1; i++) {
    long long int a;
    cin >> a;
    long long int b;
    cin >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (long long int i = 1; i <= n; i++) {
    if (g[i].size() > 2) {
      cout << -1 << '\n';
      return 0;
    }
  }
  vector<long long int> path;
  vector<bool> vis(n + 1, false);
  for (long long int i = 1; i <= n; i++) {
    if (g[i].size() == 1) {
      dfs(i, path, vis, g);
      break;
    }
  }
  long long int color[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                               {1, 2, 0}, {2, 1, 0}, {2, 0, 1}};
  long long int ans = 9223372036854775807;
  long long int id = 0;
  for (long long int i = 0; i < 6; i++) {
    long long int sum = 0;
    for (long long int j = 0; j < n; j++)
      sum += cost[color[i][j % 3]][path[j] - 1];
    if (sum < ans) {
      ans = sum;
      id = i;
    }
  }
  cout << ans << '\n';
  vector<long long int> order(n + 1, 0);
  for (long long int i = 0; i < n; i++) order[path[i]] = color[id][i % 3] + 1;
  for (long long int i = 1; i <= n; i++) cout << order[i] << " ";
  cout << '\n';
  return 0;
}
