#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> q[N];
int a[4][N];
int ans[N], vis[N], b[N];
int sta[5], n;
long long int dfs(int pos, int step, long long int cntt) {
  if (vis[pos]) return 0;
  int t = step % 3;
  if (t == 0) t = 3;
  long long sum = a[sta[t]][pos];
  b[pos] = sta[t];
  vis[pos] = 1;
  if (step == n) {
    vis[pos] = 0;
    return sum;
  }
  for (int i = 0; i < q[pos].size(); i++) {
    if (vis[q[pos][i]] == 0) {
      int now = q[pos][i];
      sum += dfs(now, step + 1, cntt);
    }
  }
  vis[pos] = 0;
  return sum;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[1][i];
  for (int i = 1; i <= n; i++) cin >> a[2][i];
  for (int i = 1; i <= n; i++) cin >> a[3][i];
  for (int i = 1; i <= n; i++) vis[i] = 0;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    q[x].push_back(y);
    q[y].push_back(x);
  }
  int pos, flag = 0;
  for (int i = 1; i <= n; i++) {
    if (q[i].size() > 2) {
      flag = 1;
      break;
    } else if (q[i].size() == 1) {
      pos = i;
    }
  }
  long long int cnt = 0, sum = 1e18;
  int k = 1;
  if (flag == 1)
    printf("-1\n");
  else {
    for (int i = 1; i <= 6; i++) {
      if (i == 1)
        sta[1] = 1, sta[2] = 2, sta[3] = 3;
      else if (i == 2)
        sta[1] = 1, sta[2] = 3, sta[3] = 2;
      else if (i == 3)
        sta[1] = 2, sta[2] = 1, sta[3] = 3;
      else if (i == 4)
        sta[1] = 2, sta[2] = 3, sta[3] = 1;
      else if (i == 5)
        sta[1] = 3, sta[2] = 1, sta[3] = 2;
      else
        sta[1] = 3, sta[2] = 2, sta[3] = 1;
      cnt = dfs(pos, 1, 0);
      if (cnt < sum) {
        for (int i = 1; i <= n; i++) ans[i] = b[i];
        sum = cnt;
      }
    }
    cout << sum << endl;
    cout << ans[1];
    for (int i = 2; i <= n; i++) {
      cout << ' ' << ans[i];
    }
  }
  return 0;
}
