#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> c(3);
vector<int> v, color, used;
vector<vector<int>> g;
void dfs(int i) {
  used[i] = 1;
  for (int j = 0; j < g[i].size(); ++j) {
    if (!used[g[i][j]]) {
      v[i] = g[i][j];
      dfs(g[i][j]);
    }
  }
}
int main() {
  long long n, x, y;
  long long sum, mi = 1e18, s;
  cin >> n;
  v.resize(n + 1);
  g.resize(n + 1);
  used.resize(n + 1);
  color.resize(n + 1);
  int used[2][n];
  for (int j = 0; j < 3; ++j) {
    c[j].resize(n);
    for (int i = 0; i < n; ++i) {
      cin >> c[j][i];
    }
  }
  if (n == 1) {
    for (int i = 0; i < 3; ++i) {
      if (c[i][0] < mi) {
        mi = c[i][0];
        x = i;
      }
    }
    cout << mi << '\n' << x + 1;
    return 0;
  }
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    if (g[x].size() > 2 || g[y].size() > 2) {
      cout << -1;
      return 0;
    }
  }
  int st;
  for (int i = 1; i < n + 1; ++i) {
    if (g[i].size() == 1) {
      dfs(i);
      st = i;
      break;
    }
  }
  int a[6][3] = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3},
                 {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};
  int d = -1;
  for (int i = 0; i < 6; ++i) {
    s = st;
    sum = c[a[i][0] - 1][s - 1];
    for (int j = 0, k = 1; j < n - 1; ++j, k++) {
      s = v[s];
      sum += c[a[i][k % 3] - 1][s - 1];
    }
    if (sum < mi) {
      mi = sum;
      d = i;
    }
  }
  cout << mi << '\n';
  color[st] = a[d][0];
  s = st;
  for (int i = 0, k = 1; i < n - 1; ++i, ++k) {
    s = v[s];
    color[s] = a[d][k % 3];
  }
  for (int i = 1; i <= n; ++i) {
    cout << color[i] << " ";
  }
}
