#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  bool HAST = 0;
  if (HAST) {
    int t;
    cin >> t;
    for (int tt = 0, _tt = (t); tt < _tt; ++tt) {
      solve();
      cout << '\n';
    }
  } else {
    solve();
  }
}
void buildsnake(vector<int>& snake, vector<vector<int> >& g, vector<bool>& u,
                int node) {
  u[node] = true;
  snake.push_back(node);
  for (int i = 0, _i = (int((g[node]).size())); i < _i; ++i) {
    int child = g[node][i];
    if (!u[child]) {
      buildsnake(snake, g, u, child);
    }
  }
}
void solve() {
  int n;
  cin >> n;
  vector<vector<int> > c(3, vector<int>(n, 0));
  for (int i = 0, _i = (3); i < _i; ++i)
    for (int j = 0, _j = (n); j < _j; ++j) cin >> c[i][j];
  vector<vector<int> > g(n);
  int v, u, maxrank = 0;
  for (int i = 0, _i = (n - 1); i < _i; ++i) {
    cin >> v >> u;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
    maxrank = max(maxrank, int((g[u - 1]).size()));
    maxrank = max(maxrank, int((g[v - 1]).size()));
  }
  if (maxrank > 2) {
    cout << -1;
  } else {
    vector<int> snake;
    snake.reserve(n);
    vector<bool> u(n, false);
    for (int i = 0, _i = (n); i < _i; ++i) {
      if (int((g[i]).size()) == 1) {
        buildsnake(snake, g, u, i);
        break;
      }
    }
    int comb[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                      {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
    long long sol = 100000000000001, solt;
    int bc;
    for (int mi = 0, _mi = (6); mi < _mi; ++mi) {
      solt = 0;
      for (int i = 0, _i = (n); i < _i; ++i)
        solt += c[comb[mi][i % 3]][snake[i]];
      if (solt < sol) {
        sol = solt;
        bc = mi;
      }
    }
    vector<int> col(n);
    for (int i = 0, _i = (n); i < _i; ++i) col[snake[i]] = comb[bc][i % 3];
    cout << sol << '\n';
    for (int i = 0, _i = (n); i < _i; ++i) cout << col[i] + 1 << ' ';
  }
}
