#include <bits/stdc++.h>
using namespace std;
const long long int N = 200005;
const long long int LG = 22;
vector<long long int> v[N], order;
long long int a[4][N], deg[N];
long long int vis[N];
void dfs(long long int u, long long int p) {
  vis[u] = 1;
  order.push_back(u);
  for (auto i : v[u]) {
    if (vis[i] == 0) {
      dfs(i, u);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= 3; i++) {
    for (long long int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  long long int mx = 0;
  for (long long int i = 0; i <= n; i++) mx = max(mx, deg[i]);
  if (mx >= 3) {
    cout << -1 << endl;
    return 0;
  }
  long long int root = 0;
  for (long long int i = 1; i <= n; i++) {
    if (deg[i] == 1) {
      root = i;
      break;
    }
  }
  dfs(root, 0);
  long long int st = 0, sum = 100000000000001;
  long long int p[] = {1, 2, 3};
  long long int ans[3];
  do {
    long long int x = 0;
    long long int c = 0;
    for (long long int j = 0; j < n; j++) {
      long long int node = order[j];
      c += a[p[x]][node];
      x++;
      if (x == 3) x = 0;
    }
    if (c < sum) {
      sum = c;
      for (long long int j = 0; j < 3; j++) ans[j] = p[j];
    }
  } while (next_permutation(p, p + 3));
  long long int x = 0;
  long long int lol[n + 1];
  cout << sum << endl;
  for (long long int i = 0; i < n; i++) {
    long long int z = order[i];
    lol[z] = ans[i % 3];
  }
  for (long long int i = 1; i <= n; i++) cout << lol[i] << ' ';
  cout << endl;
  return 0;
}
