#include <bits/stdc++.h>
using namespace std;
const int LIM = 100005;
vector<long long> culori[LIM];
vector<int> arbore[LIM];
int N;
long long rezultat;
int colorat[LIM];
int pattern[7][3]{{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                  {1, 2, 0}, {2, 1, 0}, {2, 0, 1}};
int frunza;
void citire() {
  cin >> N;
  for (int i = 1; i <= 3; i++)
    for (int i = 1; i <= N; i++) {
      int cost;
      cin >> cost;
      culori[i].push_back(cost);
    }
  for (int i = 1; i <= N - 1; i++) {
    int x, y;
    cin >> x >> y;
    arbore[x].push_back(y);
    arbore[y].push_back(x);
  }
  size_t minim = 2 * LIM;
  for (int i = 1; i <= N; i++) {
    size_t k = arbore[i].size();
    if (k < minim && k < 3) {
      minim = k;
      frunza = i;
    } else if (k == 3) {
      frunza = -1;
      i = N + 1;
    }
  }
}
long long dfs(int nod, int tata, int pattern_curent, int nr) {
  long long sum = culori[nod][pattern[pattern_curent][nr % 3]];
  colorat[nod] = pattern[pattern_curent][nr % 3];
  for (auto fiu : arbore[nod])
    if (fiu != tata) {
      sum += dfs(fiu, nod, pattern_curent, nr + 1);
    }
  return sum;
}
void rezolvare() {
  int pattern_min = 0;
  rezultat = dfs(frunza, 0, 0, 0);
  for (int i = 1; i <= 5; i++) {
    long long rez_partial = dfs(frunza, 0, i, 0);
    if (rez_partial < rezultat) {
      rezultat = rez_partial;
      pattern_min = i;
    }
  }
  cout << dfs(frunza, 0, pattern_min, 0) << endl;
  for (int i = 1; i <= N; i++) cout << colorat[i] + 1 << " ";
}
int main() {
  citire();
  if (frunza == -1)
    cout << frunza;
  else
    rezolvare();
  return 0;
}
