#include <bits/stdc++.h>
using namespace std;
template <class T>
bool mini(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool maxi(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int N = 100000;
vector<int> G[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<vector<int> > C(3, vector<int>(n));
  for (int i = 0; i < (int)(3); i++)
    for (int j = 0; j < (int)(n); j++) cin >> C[i][j];
  for (int i = 0; i < (int)(n - 1); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
    if (G[u].size() > 2 || G[v].size() > 2) return cout << -1 << "\n", 0;
  }
  long long ans = 1e18;
  vector<int> anss;
  for (int c1 = 0; c1 < (int)(3); c1++)
    for (int c2 = 0; c2 < (int)(3); c2++)
      if (c1 != c2) {
        int u = 0, v = G[u][0];
        vector<int> cor(n, -1);
        cor[u] = c1;
        cor[v] = c2;
        long long sum = C[c1][u] + C[c2][v];
        vector<pair<int, int> > st;
        st.push_back(make_pair(u, v));
        for (int cur = 0; cur < (int)(st.size()); cur++) {
          pair<int, int> x = st[cur];
          for (int cnt = 0; cnt < (int)(2); cnt++) {
            for (int v : G[x.first])
              if (cor[v] < 0) {
                st.push_back(make_pair(x.first, v));
                for (int flag = 0; flag < (int)(3); flag++)
                  if (flag != cor[x.first] && flag != cor[x.second]) {
                    sum += C[flag][v];
                    cor[v] = flag;
                  }
              }
            swap(x.first, x.second);
          }
        }
        if (mini(ans, sum)) anss = cor;
      }
  cout << ans << "\n";
  for (int v : anss) cout << v + 1 << ' ';
  cout << "\n";
}
