#include <bits/stdc++.h>
using namespace std;
vector<int> tail;
map<int, long long> a, b, c;
long long cost(int A, int B, int C) {
  long long sum = 0, ct = 0;
  for (int i : tail) {
    if (ct % 3 == 0) {
      if (A == 1) sum += a[i];
      if (A == 2) sum += b[i];
      if (A == 3) sum += c[i];
    } else if (ct % 3 == 1) {
      if (B == 1) sum += a[i];
      if (B == 2) sum += b[i];
      if (B == 3) sum += c[i];
    } else {
      if (C == 1) sum += a[i];
      if (C == 2) sum += b[i];
      if (C == 3) sum += c[i];
    }
    ct++;
  }
  return sum;
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n, val;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> val, a[i + 1] = val;
  for (int i = 0; i < n; i++) cin >> val, b[i + 1] = val;
  for (int i = 0; i < n; i++) cin >> val, c[i + 1] = val;
  vector<int> v[n + 5];
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int root = -1, ct = 0;
  for (int i = 0; i < n; i++)
    if (v[i + 1].size() == 1) ct++, root = i + 1;
  if (ct != 2) {
    cout << -1 << '\n';
    return 0;
  }
  tail.push_back(root);
  tail.push_back(v[root][0]);
  int parent = root;
  root = v[root][0];
  while (true) {
    int temp = root;
    root = ((v[root][0] == parent) ? v[root][1] : v[root][0]);
    tail.push_back(root);
    parent = temp;
    if (v[root].size() == 1) break;
  }
  int a[n + 5];
  long long ans = 1000000000000000000, sum;
  sum = cost(1, 2, 3);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 1;
      else if (i % 3 == 1)
        a[tail[i]] = 2;
      else
        a[tail[i]] = 3;
    }
  }
  sum = cost(2, 3, 1);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 2;
      else if (i % 3 == 1)
        a[tail[i]] = 3;
      else
        a[tail[i]] = 1;
    }
  }
  sum = cost(3, 1, 2);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 3;
      else if (i % 3 == 1)
        a[tail[i]] = 1;
      else
        a[tail[i]] = 2;
    }
  }
  sum = cost(3, 2, 1);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 3;
      else if (i % 3 == 1)
        a[tail[i]] = 2;
      else
        a[tail[i]] = 1;
    }
  }
  sum = cost(1, 3, 2);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 1;
      else if (i % 3 == 1)
        a[tail[i]] = 3;
      else
        a[tail[i]] = 2;
    }
  }
  sum = cost(2, 1, 3);
  if (ans > sum) {
    ans = sum;
    for (int i = 0; i < n; i++) {
      if (i % 3 == 0)
        a[tail[i]] = 2;
      else if (i % 3 == 1)
        a[tail[i]] = 1;
      else
        a[tail[i]] = 3;
    }
  }
  cout << ans << '\n';
  for (int i = 0; i < n; i++) cout << a[i + 1] << ' ';
  cout << '\n';
  return 0;
}
