#include <bits/stdc++.h>
using namespace std;
long long int col[7][3];
vector<long long int> v[500005];
long long int d = 0;
long long int n;
long long int c[4][200005];
bool visited[500005] = {false};
long long int sum = 0;
long long int ans[500005];
void dfs(long long int s, long long int br) {
  if (visited[s]) {
    d--;
    return;
  }
  long long int boja = col[br][d % 3];
  sum += c[boja - 1][s - 1];
  visited[s] = true;
  long long int i;
  for (i = 0; i < v[s].size(); i++) {
    d++;
    dfs(v[s][i], br);
  }
  d--;
}
void dfs1(long long int s, long long int br) {
  if (visited[s]) {
    d--;
    return;
  }
  long long int boja = col[br][d % 3];
  ans[s] = boja;
  visited[s] = true;
  long long int i;
  for (i = 0; i < v[s].size(); i++) {
    d++;
    dfs1(v[s][i], br);
  }
  d--;
}
int main() {
  cin >> n;
  long long int i;
  for (i = 0; i < 3; i++)
    for (long long int j = 0; j < n; j++) cin >> c[i][j];
  for (i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool ok = true;
  for (i = 1; i <= n; i++)
    if (v[i].size() > 2) ok = false;
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  long long int idx;
  for (i = 1; i <= n; i++)
    if (v[i].size() == 1) {
      idx = i;
      break;
    }
  long long int mini = 1e17;
  col[0][0] = 1;
  col[0][1] = 2;
  col[0][2] = 3;
  col[1][0] = 1;
  col[1][1] = 3;
  col[1][2] = 2;
  col[2][0] = 2;
  col[2][1] = 1;
  col[2][2] = 3;
  col[3][0] = 2;
  col[3][1] = 3;
  col[3][2] = 1;
  col[4][0] = 3;
  col[4][1] = 2;
  col[4][2] = 1;
  col[5][0] = 3;
  col[5][1] = 1;
  col[5][2] = 2;
  long long int koji;
  dfs(idx, 0);
  if (mini > sum) {
    mini = sum;
    koji = 0;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  dfs(idx, 1);
  if (mini > sum) {
    mini = sum;
    koji = 1;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  dfs(idx, 2);
  if (mini > sum) {
    mini = sum;
    koji = 2;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  dfs(idx, 3);
  if (mini > sum) {
    mini = sum;
    koji = 3;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  dfs(idx, 4);
  if (mini > sum) {
    mini = sum;
    koji = 4;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  dfs(idx, 5);
  if (mini > sum) {
    mini = sum;
    koji = 5;
  }
  d = 0;
  sum = 0;
  for (i = 1; i <= n; i++) visited[i] = false;
  cout << mini << endl;
  dfs1(idx, koji);
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
