#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 11;
long long cs[4][N], n, dp[N][4][4];
vector<int> g[N], ord;
bool u[N];
void dfs(int v) {
  u[v] = 1;
  ord.push_back(v);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!u[to]) dfs(to);
  }
}
pair<long long, vector<int> > f(int x, int y) {
  long long res = 0;
  vector<int> g(n + 1);
  g[ord[0]] = x;
  g[ord[1]] = y;
  res += cs[x][ord[0]] + cs[y][ord[1]];
  for (int i = 2; i < n; i++) {
    int cur = ord[i];
    int col = 6 - x - y;
    res += cs[col][cur];
    g[cur] = col;
    x = y;
    y = col;
  }
  return make_pair(res, g);
}
void solve() {
  cin >> n;
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++) cin >> cs[i][j];
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (g[i].size() > 2) {
      cout << -1;
      return;
    } else if (g[i].size() == 1)
      cnt++;
  if (cnt != 2) {
    cout << -1;
    return;
  }
  int st = 0;
  for (int i = 1; i <= n; i++)
    if (g[i].size() == 1) st = i;
  dfs(st);
  pair<long long, vector<int> > ans = min(
      min(f(1, 2), f(1, 3)), min(min(f(2, 1), f(2, 3)), min(f(3, 1), f(3, 2))));
  cout << ans.first << "\n";
  for (int i = 1; i <= n; i++) cout << ans.second[i] << " ";
}
int main() {
  ;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tt = 1;
  for (int i = 1; i <= tt; i++) {
    solve();
  }
  return 0;
}
