#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long c[3][n];
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) cin >> c[i][j];
  vector<long long> v[n + 1];
  for (int i = 0; i < n - 1; i++) {
    int m, n;
    cin >> m >> n;
    v[n].push_back(m);
    v[m].push_back(n);
  }
  int index;
  for (int i = 1; i <= n; i++) {
    if (v[i].size() > 2) return puts("-1"), 0;
    if (v[i].size() == 1) index = i;
  }
  vector<int> p = {0, 1, 2};
  vector<int> a;
  for (int i = 0; i < n; i++) {
    a.push_back(index);
    if (v[index][0] != a[i - 1])
      index = v[index][0];
    else
      index = v[index][1];
  }
  long long ans = LLONG_MAX, temp;
  vector<int> t1;
  int an[n + 1];
  do {
    temp = 0;
    for (int i = 0; i < n; i++) {
      temp += c[p[i % 3]][a[i] - 1];
    }
    if (ans > temp) {
      ans = temp;
      t1 = p;
    }
  } while (next_permutation(p.begin(), p.end()));
  cout << ans << endl;
  for (int i = 0; i < n; i++) an[a[i]] = t1[i % 3] + 1;
  for (int i = 1; i <= n; i++) cout << an[i] << "\n";
}
