#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;
int n;
int degree[N];
long long int cost[N][5];
vector<int> graph[N];
long long int dp[N][5][5];
int ans[N];
long long int solve(int s, int p, int pcol, int gpcol, int remnode) {
  if (dp[s][pcol][gpcol] != -1) return dp[s][pcol][gpcol];
  long long int ret = INF;
  if (remnode == 1) {
    long long int temp = INF;
    for (int i = 1; i <= 3; i++) {
      if (pcol != i && gpcol != i) temp = min(temp, cost[s][i]);
    }
    return temp;
  }
  for (auto x : graph[s]) {
    if (x != p) {
      for (int col = 1; col <= 3; col++) {
        if (col != pcol && col != gpcol) {
          ret = min(ret, cost[s][col] + solve(x, s, col, pcol, remnode - 1));
        }
      }
    }
  }
  return dp[s][pcol][gpcol] = ret;
}
void print(int s, int p, int pcol, int gpcol, int remnode, long long int mn) {
  if (remnode == 1) {
    long long int temp = INF;
    int c = -1;
    for (int i = 1; i <= 3; i++) {
      if (i != pcol && i != gpcol) {
        if (cost[s][i] < temp) temp = cost[s][i], c = i;
      }
    }
    assert(mn == cost[s][c] && c != -1);
    ans[s] = c;
    return;
  }
  for (auto x : graph[s]) {
    if (x != p) {
      for (int col = 1; col <= 3; col++) {
        if (col != pcol && col != gpcol) {
          if (cost[s][col] + solve(x, s, col, pcol, remnode - 1) == mn) {
            ans[s] = col;
            print(x, s, col, pcol, remnode - 1, mn - cost[s][col]);
            return;
          }
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> cost[j][i];
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    degree[u]++;
    degree[v]++;
  }
  for (int i = 1; i <= n; i++)
    if (degree[i] >= 3) return cout << -1 << "\n", 0;
  int root = -1;
  for (int i = 1; i <= n; i++)
    if (degree[i] == 1) root = i;
  memset(dp, -1, sizeof(dp));
  long long int mn = solve(root, 0, 0, 0, n);
  cout << mn << "\n";
  print(root, 0, 0, 0, n, mn);
  for (int i = 1; i <= n; i++) assert(ans[i] != -1);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
