#include <bits/stdc++.h>
using namespace std;
long long Min(long long a, long long b) {
  if (a >= b)
    return b;
  else
    return a;
}
long long Max(long long a, long long b) {
  if (a >= b)
    return a;
  else
    return b;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, s = -1;
  cin >> n;
  vector<long long> a(n), b(n), c(n);
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) cin >> b[i];
  for (i = 0; i < n; ++i) cin >> c[i];
  vector<vector<long long> > g(n + 1);
  for (i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    if (g[i].size() >= 3) {
      cout << -1;
      exit(0);
    }
    if (g[i].size() == 1) s = i;
  }
  if (n == 3 && s == -1) {
    vector<long long> sq;
    sq.push_back(a[0] + b[1] + c[2]);
    sq.push_back(a[0] + c[1] + b[2]);
    sq.push_back(b[0] + a[1] + c[2]);
    sq.push_back(b[0] + c[1] + a[2]);
    sq.push_back(c[0] + b[1] + a[2]);
    sq.push_back(c[0] + a[1] + b[2]);
    sort(sq.begin(), sq.end());
    cout << sq[0] << endl;
    if (a[0] + b[1] + c[2] == sq[0])
      cout << 1 << " " << 2 << " " << 3;
    else if (a[0] + c[1] + b[2] == sq[0])
      cout << 1 << " " << 3 << " " << 2;
    else if (b[0] + a[1] + c[2] == sq[0])
      cout << 2 << " " << 1 << " " << 3;
    else if (b[0] + c[1] + a[2] == sq[0])
      cout << 2 << " " << 3 << " " << 1;
    else if (c[0] + a[1] + b[2] == sq[0])
      cout << 3 << " " << 1 << " " << 2;
    else
      cout << 3 << " " << 2 << " " << 1;
    exit(0);
  }
  i = 0;
  int p[] = {0, 1, 2};
  long long mi = pow(10, 18), w1, w2, w3;
  do {
    long long point = 0, temp = 0, prev = -1, i = s;
    do {
      long long z = p[point];
      point++;
      point %= 3;
      if (z == 0)
        temp += a[i - 1];
      else if (z == 1)
        temp += b[i - 1];
      else
        temp += c[i - 1];
      for (long long k = 0; k < g[i].size(); k++) {
        if (g[i][k] != prev) {
          prev = i;
          i = g[i][k];
          break;
        }
      }
    } while (g[i].size() > 1);
    long long z = p[point];
    point++;
    point %= 3;
    if (z == 0)
      temp += a[i - 1];
    else if (z == 1)
      temp += b[i - 1];
    else
      temp += c[i - 1];
    if (mi > temp) {
      mi = temp;
      w1 = p[0] + 1;
      w2 = p[1] + 1;
      w3 = p[2] + 1;
    }
  } while (next_permutation(p, p + 3));
  cout << mi << endl;
  i = s;
  long long prev = -1;
  vector<long long> ans(n);
  p[0] = w1;
  p[1] = w2;
  p[2] = w3;
  long long coun = 1;
  ans[i - 1] = p[0];
  for (long long k = 0; k < g[i].size(); k++) {
    if (g[i][k] != prev) {
      ans[g[i][k] - 1] = p[coun];
      coun++;
      coun %= 3;
      prev = i;
      i = g[i][k];
      k = -1;
    }
  }
  for (i = 0; i < n; i++) cout << ans[i] << " ";
  return 0;
}
