#include <bits/stdc++.h>
using namespace std;
long long nx2(long long n) {
  long long p = 1;
  if (n && !(n & (n - 1))) return n;
  while (p < n) p <<= 1;
  return p;
}
namespace Debug {
void dout() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << " " << H;
  dout(T...);
}
template <typename T>
void douta(const T *a, int n) {
  cerr << "\n[";
  for (int i = 0; i < n; i++) {
    cerr << " " << a[i];
  }
  cerr << " ]\n";
}
template <typename T>
void doutaa(T **b, int r, int c) {
  for (int i = 0; i < r; i++) {
    cerr << "[";
    for (int j = 0; j < c; j++) {
      cerr << " " << b[i][j];
    }
    cerr << " ]\n";
  }
}
template <typename T>
void dout(const vector<T> v) {
  cerr << "\n[";
  for (T i : v) {
    cerr << " " << i;
  }
  cerr << " ]\n";
}
template <typename T>
void dout(const vector<vector<T>> v) {
  cerr << "\n";
  for (vector<T> u : v) {
    cerr << "[";
    for (T i : u) {
      cerr << " " << i;
    }
    cerr << " ]\n";
  }
}
template <typename F, typename S>
void dout(const vector<pair<F, S>> u) {
  cerr << "\n";
  for (pair<F, S> v : u) {
    cerr << "[ " << v.first << " " << v.second << " ]\n";
  }
}
}  // namespace Debug
using namespace Debug;
const int N = 1e5 + 69;
vector<int> adj[N], arr;
int col[N][3];
pair<int, int> prr[N];
void dfs(int u, int par) {
  arr.push_back(u);
  for (auto v : adj[u]) {
    if (v != par) {
      dfs(v, u);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      cin >> col[j][i];
    }
  }
  int valid = 1;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v, --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    if (adj[u].size() > 2 || adj[v].size() > 2) {
      valid = 0;
    }
  }
  if (!valid) {
    cout << -1 << '\n';
    return 0;
  }
  int start, prev;
  for (int i = 0; i < n; i++) {
    if (adj[i].size() == 1) {
      start = i, prev = i;
      break;
    }
  }
  arr.clear();
  dfs(start, -1);
  vector<vector<int>> perms(
      {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}});
  long long ans = LLONG_MAX;
  vector<int> minperm;
  for (auto &perm : perms) {
    long long cost = 0;
    for (int i = 0; i < n; ++i) {
      cost += (long long)col[arr[i]][perm[i % 3]];
    }
    if (ans > cost) {
      ans = cost;
      minperm = perm;
    }
  }
  cout << ans << '\n';
  for (int i = 0; i < n; i++) {
    prr[i] = make_pair(arr[i], i);
  }
  sort(prr, prr + n);
  for (int i = 0; i < n; i++) {
    cout << minperm[prr[i].second % 3] + 1 << " ";
  }
  cout << '\n';
}
