#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
static const auto do_fast_io = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return nullptr;
}();
vector<int> perm = {0, 1, 2};
vector<int> node_colors;
vector<vector<int>> c;
vector<vector<int>> graph;
long long dfs_recursion(int s, int p, int idx) {
  node_colors[s] = perm[idx];
  long long curr = c[s][perm[idx]];
  long long after = 0;
  for (auto i : graph[s]) {
    if (i != p) {
      after = dfs_recursion(i, s, (idx + 1) % 3);
    }
  }
  return curr + after;
}
int main() {
  int n;
  cin >> n;
  c.resize(n + 1, vector<int>(3));
  graph.resize(n + 1);
  node_colors.resize(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> c[i][0];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> c[i][1];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> c[i][2];
  }
  for (int i = 1; i <= n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
    if (graph[x].size() > 2 || graph[y].size() > 2) {
      cout << -1 << endl;
      return 0;
    }
  }
  int root = 0;
  for (int i = 1; i <= n; ++i) {
    if (graph[i].size() == 1) {
      root = i;
    }
  }
  long long min_cost = LONG_LONG_MAX;
  vector<int> min_cost_colors_seq;
  do {
    long long cost = dfs_recursion(root, 0, 0);
    if (cost < min_cost) {
      min_cost = cost;
      min_cost_colors_seq = node_colors;
    }
  } while (next_permutation(perm.begin(), perm.end()));
  cout << min_cost << endl;
  for (int i = 1; i <= n; ++i) {
    cout << min_cost_colors_seq[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
