#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e6;
long long int c[3][N];
vector<long long int> v[N], x1, x2, x3, x4, x5, x6, w;
bool mark[N];
void dfs(long long int x) {
  mark[x] = true;
  w.push_back(x);
  for (auto i : v[x])
    if (!mark[i]) dfs(i);
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < 3; i++) {
    for (long long int j = 0; j < n; j++) {
      cin >> c[i][j];
    }
  }
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x - 1].push_back(y - 1);
    v[y - 1].push_back(x - 1);
  }
  long long int p = 0;
  for (long long int i = 0; i < n; i++)
    if (v[i].size() > 2) return cout << -1, 0;
  for (long long int i = 0; i < n; i++) {
    if (v[i].size() == 1) {
      p = i;
      break;
    }
  }
  for (long long int i = 0; i < n; i++) {
    x1.push_back(-1);
    x2.push_back(-1);
    x3.push_back(-1);
    x4.push_back(-1);
    x5.push_back(-1);
    x6.push_back(-1);
  }
  dfs(p);
  long long int y1 = 0, y2 = 0, y3 = 0, y4 = 0, y5 = 0, y6 = 0, q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x1[i] = 1, y1 += c[0][i];
    if (q % 3 == 1) x1[i] = 2, y1 += c[1][i];
    if (q % 3 == 2) x1[i] = 3, y1 += c[2][i];
    q++;
  }
  q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x2[i] = 1, y2 += c[0][i];
    if (q % 3 == 1) x2[i] = 3, y2 += c[2][i];
    if (q % 3 == 2) x2[i] = 2, y2 += c[1][i];
    q++;
  }
  q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x3[i] = 2, y3 += c[1][i];
    if (q % 3 == 1) x3[i] = 1, y3 += c[0][i];
    if (q % 3 == 2) x3[i] = 3, y3 += c[2][i];
    q++;
  }
  q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x4[i] = 2, y4 += c[1][i];
    if (q % 3 == 1) x4[i] = 3, y4 += c[2][i];
    if (q % 3 == 2) x4[i] = 1, y4 += c[0][i];
    q++;
  }
  q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x5[i] = 3, y5 += c[2][i];
    if (q % 3 == 1) x5[i] = 1, y5 += c[0][i];
    if (q % 3 == 2) x5[i] = 2, y5 += c[1][i];
    q++;
  }
  q = 0;
  for (auto i : w) {
    if (q % 3 == 0) x6[i] = 3, y6 += c[2][i];
    if (q % 3 == 1) x6[i] = 2, y6 += c[1][i];
    if (q % 3 == 2) x6[i] = 1, y6 += c[0][i];
    q++;
  }
  long long int fin = 1e15;
  fin = min(fin, min(y1, min(y2, min(y3, min(y4, min(y5, y6))))));
  cout << fin << "\n";
  if (fin == y1) {
    for (auto i : x1) cout << i << " ";
    return 0;
  }
  if (fin == y2) {
    for (auto i : x2) cout << i << " ";
    return 0;
  }
  if (fin == y3) {
    for (auto i : x3) cout << i << " ";
    return 0;
  }
  if (fin == y4) {
    for (auto i : x4) cout << i << " ";
    return 0;
  }
  if (fin == y5) {
    for (auto i : x5) cout << i << " ";
    return 0;
  }
  if (fin == y6) {
    for (auto i : x6) cout << i << " ";
    return 0;
  }
}
