#include <bits/stdc++.h>
using namespace std;
template <typename first, typename second>
ostream &operator<<(ostream &os, const pair<first, second> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  typename vector<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  typename set<T>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  typename map<first, second>::const_iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
long long dp[100005][3];
vector<vector<long long> > adj;
long long col[100005];
map<long long, long long> Order;
map<long long, long long> revOrder;
long long Ct = 0;
void dfs(long long x, long long p) {
  ++Ct;
  Order[Ct] = x;
  for (auto g : adj[x]) {
    if (g != p) {
      dfs(g, x);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<long long> c1(n);
  vector<long long> c2(n);
  vector<long long> c3(n);
  for (long long i = 0; i < n; i++) {
    cin >> c1[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c2[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c3[i];
  }
  adj.resize(n + 1);
  for (long long i = 0; i < (n - 1); i++) {
    long long U, V;
    cin >> U >> V;
    adj[U].push_back(V);
    adj[V].push_back(U);
  }
  long long f = 1;
  for (long long i = 1; i <= n; i++) {
    if (adj[i].size() > 2) {
      f = 0;
    }
  }
  if (f == 0) {
    cout << -1 << "\n";
  } else {
    long long root = 0;
    for (long long i = 1; i <= n; i++) {
      if (adj[i].size() == 1) {
        root = i;
        break;
      }
    }
    dfs(root, 0);
    memset(col, 0, sizeof(col));
    vector<long long> perm;
    perm.push_back(1);
    perm.push_back(2);
    perm.push_back(3);
    long long Cost = 1e18;
    vector<long long> Correct;
    do {
      long long temp = 0;
      for (long long i = 1; i <= n; i++) {
        long long cur = Order[i] - 1;
        long long D = i % 3;
        if (D == 0) {
          if (perm[2] == 1) temp += c1[cur];
          if (perm[2] == 2) temp += c2[cur];
          if (perm[2] == 3) temp += c3[cur];
        } else if (D == 1) {
          if (perm[0] == 1) temp += c1[cur];
          if (perm[0] == 2) temp += c2[cur];
          if (perm[0] == 3) temp += c3[cur];
        } else {
          if (perm[1] == 1) temp += c1[cur];
          if (perm[1] == 2) temp += c2[cur];
          if (perm[1] == 3) temp += c3[cur];
        }
      }
      if (temp < Cost) {
        Cost = temp;
        Correct = perm;
      }
    } while (next_permutation(perm.begin(), perm.end()));
    cout << Cost << "\n";
    for (long long i = 1; i <= n; i++) {
      long long cur = Order[i];
      long long D = i % 3;
      if (D == 0) {
        D = 2;
      } else if (D == 1) {
        D = 0;
      } else if (D == 2) {
        D = 1;
      }
      if (Correct[D] == 1) {
        col[cur] = 1;
      } else if (Correct[D] == 2) {
        col[cur] = 2;
      } else {
        col[cur] = 3;
      }
    }
    for (long long i = 1; i <= n; i++) {
      cout << col[i] << " ";
    }
    cout << "\n";
  }
  return 0;
}
