#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
long long cnt[N], c[4][N], x, y, n, ans[N], answer[N], price, mn = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  vector<int> g[n + 1];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= n; i++) {
      cin >> c[j][i];
    }
  }
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    cnt[x]++;
    cnt[y]++;
  }
  int parent;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > 2) {
      cout << -1;
      return 0;
    }
    if (cnt[i] == 1) parent = i;
  }
  vector<int> vc{1, 2, 3};
  do {
    vector<int> used(N, 0);
    function<void(int, int, int)> dfs = [&](int v, int c1, int c2) {
      used[v] = 1;
      for (auto u : g[v]) {
        if (!used[u]) {
          for (int i = 1; i <= 3; i++) {
            if (i != c1 && i != c2) {
              ans[u] = i;
              dfs(u, c2, i);
            }
          }
        }
      }
    };
    ans[parent] = vc[0];
    used[parent] = 1;
    ans[g[parent][0]] = vc[1];
    used[g[parent][0]] = 1;
    for (auto u : g[g[parent][0]]) {
      if (u != parent) {
        ans[u] = vc[2];
        dfs(u, vc[1], vc[2]);
        break;
      }
    }
    price = 0;
    for (int i = 1; i <= n; i++) {
      price += c[ans[i]][i];
    }
    if (price < mn) {
      for (int i = 1; i <= n; i++) answer[i] = ans[i];
      mn = price;
    }
  } while (next_permutation(vc.begin(), vc.end()));
  cout << mn << endl;
  for (int i = 1; i <= n; i++) cout << answer[i] << ' ';
}
