#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int maxe = 20;
const unsigned long long int OO = INFINITY;
const int oo = 1 << 30;
unsigned long long int t[3][maxn], ans[6], res[maxn], k;
int sec[6][3] = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3},
                 {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};
int n, arr[maxn];
set<int> ady[maxn];
int main() {
  scanf("%d", &n);
  for (__typeof(3) i = (0) - ((0) > (3)); i != (3) - ((0) > (3));
       i += 1 - 2 * ((0) > (3)))
    for (int j = 1; j <= n; j++) cin >> t[i][j];
  int a, b, root;
  for (__typeof(n) i = (1) - ((1) > (n)); i != (n) - ((1) > (n));
       i += 1 - 2 * ((1) > (n))) {
    cin >> a >> b;
    ady[a].insert(b);
    ady[b].insert(a);
    if (ady[a].size() >= 3 || ady[b].size() >= 3) {
      cout << -1;
      return 0;
    }
  }
  for (__typeof(n + 1) i = (1) - ((1) > (n + 1));
       i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {
    if ((int)(ady[i].size()) == 1) {
      root = i;
      break;
    }
  }
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    arr[i] = root;
    if (!ady[root].empty()) root = *ady[root].begin();
    ady[root].erase(arr[i]);
  }
  for (__typeof(6) i = (0) - ((0) > (6)); i != (6) - ((0) > (6));
       i += 1 - 2 * ((0) > (6))) {
    k = 0;
    for (__typeof(n) j = (0) - ((0) > (n)); j != (n) - ((0) > (n));
         j += 1 - 2 * ((0) > (n))) {
      ans[i] += t[sec[i][k] - 1][arr[j]];
      k = (k + 1) % 3;
    }
  }
  k = OO, a = 0;
  for (__typeof(6) i = (0) - ((0) > (6)); i != (6) - ((0) > (6));
       i += 1 - 2 * ((0) > (6))) {
    if (ans[i] < k) {
      k = ans[i];
      a = i;
    }
  }
  cout << k << '\n';
  k = 0;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    res[arr[i] - 1] = sec[a][k];
    k = (k + 1) % 3;
  }
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cout << res[i] << ' ';
}
