#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> adjList(n);
  map<int, int> vertDegree;
  map<int, int> cost1;
  map<int, int> cost2;
  map<int, int> cost3;
  for (int i = 1; i <= n; ++i) {
    cin >> cost1[i];
    vertDegree[i] = 0;
  }
  for (int i = 1; i <= n; ++i) cin >> cost2[i];
  for (int i = 1; i <= n; ++i) cin >> cost3[i];
  int u, v;
  for (int i = 0; i < n - 1; ++i) {
    cin >> u >> v;
    adjList[u - 1].push_back(v);
    adjList[v - 1].push_back(u);
    vertDegree[u]++;
    vertDegree[v]++;
  }
  int leaf;
  for (int i = 1; i <= n; ++i) {
    if (vertDegree[i] > 2) {
      cout << -1 << endl;
      return 0;
    }
    if (vertDegree[i] == 1) leaf = i;
  }
  long long minColCost = LLONG_MAX;
  map<int, int> ansCol;
  int transpos[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                        {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
  for (int i = 0; i < 6; ++i) {
    map<int, int> tmpCol;
    long long curColcost = 0;
    int pos = 0;
    int curCol = transpos[i][pos];
    int used = -1;
    bool all = false;
    for (int g = leaf; !all;) {
      tmpCol[g] = curCol;
      if (curCol == 0)
        curColcost += cost1[g];
      else if (curCol == 1)
        curColcost += cost2[g];
      else
        curColcost += cost3[g];
      tmpCol[g] = curCol;
      pos = (pos + 1) % 3;
      curCol = transpos[i][pos];
      for (auto it = adjList[g - 1].begin(); it != adjList[g - 1].end(); ++it) {
        if (*it != used) {
          all = false;
          used = g;
          g = *it;
          break;
        } else {
          all = true;
        }
      }
    }
    if (curColcost <= minColCost) {
      minColCost = curColcost;
      ansCol = tmpCol;
    }
  }
  cout << minColCost << endl;
  for (int i = 1; i <= n; ++i) cout << ansCol[i] + 1 << " ";
  cout << endl;
  return 0;
}
