#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  std::cin >> n;
  std::vector<std::vector<long long> > c(3, std::vector<long long>(n));
  for (signed i = 0; i < n; i++) cin >> c[0][i];
  for (signed i = 0; i < n; i++) cin >> c[1][i];
  for (signed i = 0; i < n; i++) cin >> c[2][i];
  std::vector<std::vector<long long> > gr(n);
  for (signed i = 0; i < n - 1; i++) {
    long long a;
    std::cin >> a;
    long long b;
    std::cin >> b;
    a--;
    b--;
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  for (signed i = 0; i < n; i++) {
    if (gr[i].size() > 2) {
      cout << "-1";
      return;
    }
  }
  std::vector<long long> w;
  for (signed i = 0; i < n; i++) {
    if (gr[i].size() == 1) {
      w.push_back(i);
      w.push_back(gr[i][0]);
      break;
    }
  }
  for (; gr[w.back()].size() == 2;) {
    if (gr[w.back()][0] != w[w.size() - 2])
      w.push_back(gr[w.back()][0]);
    else
      w.push_back(gr[w.back()][1]);
  }
  std::pair<long long, long long> ans;
  long long msum = 2000000000000000001;
  for (signed first = 0; first < 3; first++) {
    for (signed second = 0; second < 3; second++) {
      if (first == second) continue;
      long long sum = 0;
      for (signed i = 0; i < n; i++) {
        if (i % 3 == 0) {
          sum += c[first][w[i]];
        } else if (i % 3 == 1) {
          sum += c[second][w[i]];
        } else {
          sum += c[3 - first - second][w[i]];
        }
      }
      if (sum < msum) {
        msum = sum;
        ans = {first, second};
      }
    }
  }
  cout << msum << '\n';
  std::vector<long long> res(n);
  for (signed i = 0; i < n; i++) {
    if (i % 3 == 0) {
      res[w[i]] = ans.first + 1;
    } else if (i % 3 == 1) {
      res[w[i]] = ans.second + 1;
    } else {
      res[w[i]] = 3 - ans.second - ans.first + 1;
    }
  }
  for (signed i = 0; i < n; i++) cout << res[i] << ' ';
}
signed main(signed argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (argc > 1 && (string)argv[1] == "local") {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  solve();
  return 0;
}
