#include <bits/stdc++.h>
using namespace std;
const long double PI = 2 * acos(0.);
template <class T>
void read(vector<T>& v) {
  for (long long i = 0; i < v.size(); ++i) {
    cin >> v[i];
  }
}
vector<vector<long long>> vv = {
    {0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0},
};
void solve() {
  long long n;
  cin >> n;
  vector<vector<long long>> c(3, vector<long long>(n));
  vector<vector<long long>> g(n);
  read(c[0]);
  read(c[1]);
  read(c[2]);
  for (long long i = 0; i < n - 1; ++i) {
    long long a;
    long long b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    if (g[a].size() > 2 || g[b].size() > 2) {
      cout << -1 << endl;
      return;
    }
  }
  long long st = -1;
  for (long long i = 0; i < n; ++i) {
    if (g[i].size() == 1) {
      st = i;
      break;
    }
  }
  long long ans = std::numeric_limits<long long>::max();
  vector<long long> aa;
  for (const auto& p : vv) {
    long long loc_ans = 0;
    int prev = -1;
    int cur = st;
    for (int i = 0; i < n; ++i) {
      loc_ans += c[p[i % 3]][cur];
      int to = g[cur][0];
      if (to == prev) {
        if (g[cur].size() > 1) {
          to = g[cur][1];
        }
      }
      prev = cur;
      cur = to;
    }
    if (loc_ans < ans) {
      ans = loc_ans;
      aa = p;
    }
  }
  cout << ans << endl;
  vector<int> aaa(n);
  int prev = -1;
  int cur = st;
  for (int i = 0; i < n; ++i) {
    aaa[cur] = aa[i % 3] + 1;
    int to = g[cur][0];
    if (to == prev) {
      if (g[cur].size() > 1) {
        to = g[cur][1];
      }
    }
    prev = cur;
    cur = to;
  }
  for (int i = 0; i < n; ++i) {
    cout << aaa[i] << " ";
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
