#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
vector<int> v;
int vis[100005], w[5][100005], ans[100005];
int color[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2},
                   {1, 2, 0}, {2, 1, 0}, {2, 0, 1}};
void dfs(int x) {
  vis[x] = 1;
  v.push_back(x);
  int len = g[x].size();
  for (int i = 0; i < len; i++) {
    int temp = g[x][i];
    if (vis[temp] == 0) {
      dfs(temp);
    }
  }
}
int main() {
  int n, a, b;
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &w[i][j]);
    }
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (g[i].size() > 2) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (g[i].size() == 1) {
      dfs(i);
      break;
    }
  }
  long long sum = 0, Min = 1e18;
  int pos;
  for (int i = 0; i < 6; i++) {
    sum = 0;
    for (int j = 0; j < v.size(); j++) {
      sum += w[color[i][j % 3]][v[j]];
    }
    if (sum < Min) {
      Min = sum;
      pos = i;
    }
  }
  for (int i = 0; i < n; i++) {
    ans[v[i]] = color[pos][i % 3] + 1;
  }
  printf("%lld\n", Min);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
