#include <bits/stdc++.h>
using namespace std;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  long long idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ", ";
  dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const long long N = 100007;
vector<long long> v[N];
vector<long long> path;
void dfs(long long x, long long p = -1) {
  path.push_back(x);
  for (auto& i : v[x]) {
    if (i != p) dfs(i, x);
  }
}
void solve() {
  long long i, j, k, n, m, q;
  long long x, y, l, r;
  cin >> n;
  long long cost[n + 1][3];
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> cost[j + 1][i];
    }
  }
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y), v[y].push_back(x);
    if (v[x].size() >= 3 or v[y].size() >= 3) {
      cout << -1 << endl;
      return;
    }
  }
  if (n == 1) {
    long long mn = LLONG_MAX, foo;
    for (long long i = 0; i < 3; i++) {
      if (cost[1][i] < mn) {
        mn = cost[1][i], foo = i;
      }
    }
    cout << foo + 1 << endl;
    return;
  }
  long long id;
  for (long long i = 1; i <= n; i++) {
    if (v[i].size() == 1) {
      id = i;
      break;
    }
  }
  dfs(id);
  vector<vector<long long> > type = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                                     {1, 2, 0}, {2, 1, 0}, {2, 0, 1}};
  long long mn_cost = LLONG_MAX, cur_cost, foo;
  for (long long i = 0; i < 6; i++) {
    cur_cost = 0;
    for (long long j = 0; j < n; j++) {
      cur_cost += cost[path[j]][type[i][j % 3]];
    }
    if (cur_cost < mn_cost) {
      mn_cost = cur_cost, foo = i;
    }
  }
  vector<long long> colors(n + 1);
  for (long long i = 0; i < n; i++) {
    colors[path[i]] = type[foo][i % 3];
  }
  cout << mn_cost << endl;
  for (long long i = 1; i <= n; i++) cout << colors[i] + 1 << " ";
  cout << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  for (long long pp = 1; pp <= t; pp++) {
    solve();
  }
  return 0;
}
