#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &output, const vector<T> &v) {
  if (v.empty()) return output;
  for (int i = 0; i < v.size() - 1; i++) output << v[i] + 1 << " ";
  output << v.back() + 1;
  return output;
}
template <typename T>
istream &operator>>(istream &input, vector<T> &v) {
  for (auto &i : v) cin >> i;
  return input;
}
const int N = 1e5 + 10;
int cost[N][3];
vector<int> g[N];
long long int dfs(int node, int par, vector<int> &col) {
  long long int ans = 0;
  for (auto &i : g[node]) {
    if (i != par) {
      int curr = 3 - col[node - 1] - col[par - 1];
      col[i - 1] = curr;
      ans += cost[i][curr] + dfs(i, node, col);
    }
  }
  return ans;
}
void __sol() {
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) cin >> cost[j + 1][i];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  int fst = 1;
  for (int i = 1; i <= n; i++) {
    if (g[i].size() >= 3) {
      cout << "-1\n";
      return;
    }
    if (g[i].size() == 1) fst = i;
  }
  int sec = g[fst][0];
  long long int ans = 1000000000000000000;
  vector<int> res;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (i == j) continue;
      vector<int> col(n, -1);
      col[fst - 1] = i;
      col[sec - 1] = j;
      long long int cnt = cost[fst][i] + cost[sec][j] + dfs(sec, fst, col);
      if (cnt < ans) {
        ans = cnt;
        res = col;
      }
    }
  }
  cout << ans << "\n" << res;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  while (tc--) __sol();
  return 0;
}
