#include <bits/stdc++.h>
using namespace std;
double max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int min(long long int a, long long int b) {
  if (a < b)
    return a;
  else
    return b;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
vector<long long int> vec[100005];
long long int arr[3][100005];
vector<long long int> vec2;
void dfs(long long int node, long long int par) {
  for (auto itr : vec[node]) {
    if (itr == par) continue;
    vec2.push_back(itr);
    dfs(itr, node);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t, i, j, m, l, r, ta, tb, k, cl, ce, v, q, x1, y1, x2, y2, s, f,
      y, x, z, u, n;
  cin >> n;
  for (i = 0; i < 3; i++) {
    for (j = 1; j <= n; j++) {
      cin >> arr[i][j];
    }
  }
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  long long int root = -1;
  for (i = 1; i <= n; i++) {
    if (vec[i].size() >= 3) {
      cout << "-1";
      return 0;
    }
    if (vec[i].size() == 1) root = i;
  }
  vec2.push_back(root);
  dfs(root, 0);
  long long int index = -1, ans = 600000000000000000, flag = 0;
  long long int ans2[n + 5];
  long long int sum = 0;
  for (i = 0; i < vec2.size(); i++) {
    flag %= 3;
    long long int node = vec2[i];
    sum += arr[flag][node];
    flag++;
  }
  if (sum < ans) {
    ans = sum;
    index = 0;
    for (i = 0; i < vec2.size(); i++) {
      index %= 3;
      long long int node = vec2[i];
      ans2[node] = index;
      index++;
    }
  }
  sum = 0, flag = 1;
  for (i = 0; i < vec2.size(); i++) {
    flag %= 3;
    long long int node = vec2[i];
    sum += arr[flag][node];
    flag++;
  }
  if (sum < ans) {
    ans = sum;
    index = 1;
    for (i = 0; i < vec2.size(); i++) {
      index %= 3;
      long long int node = vec2[i];
      ans2[node] = index;
      index++;
    }
  }
  sum = 0, flag = 2;
  for (i = 0; i < vec2.size(); i++) {
    flag %= 3;
    long long int node = vec2[i];
    sum += arr[flag][node];
    flag++;
  }
  if (sum < ans) {
    ans = sum;
    index = 2;
    for (i = 0; i < vec2.size(); i++) {
      index %= 3;
      long long int node = vec2[i];
      ans2[node] = index;
      index++;
    }
  }
  sum = 0, flag = 0;
  for (i = 0; i < vec2.size(); i++) {
    long long int node = vec2[i];
    sum += arr[flag][node];
    if (flag == 0)
      flag = 2;
    else if (flag == 2)
      flag = 1;
    else if (flag == 1)
      flag = 0;
  }
  if (sum < ans) {
    ans = sum;
    flag = 0;
    for (i = 0; i < vec2.size(); i++) {
      long long int node = vec2[i];
      ans2[node] = flag;
      if (flag == 0)
        flag = 2;
      else if (flag == 2)
        flag = 1;
      else if (flag == 1)
        flag = 0;
    }
  }
  sum = 0, flag = 1;
  for (i = 0; i < vec2.size(); i++) {
    long long int node = vec2[i];
    sum += arr[flag][node];
    if (flag == 1)
      flag = 0;
    else if (flag == 0)
      flag = 2;
    else if (flag == 2)
      flag = 1;
  }
  if (sum < ans) {
    ans = sum;
    flag = 1;
    for (i = 0; i < vec2.size(); i++) {
      long long int node = vec2[i];
      ans2[node] = flag;
      if (flag == 1)
        flag = 0;
      else if (flag == 0)
        flag = 2;
      else if (flag == 2)
        flag = 1;
    }
  }
  sum = 0, flag = 2;
  for (i = 0; i < vec2.size(); i++) {
    long long int node = vec2[i];
    sum += arr[flag][node];
    if (flag == 2)
      flag = 1;
    else if (flag == 1)
      flag = 0;
    else if (flag == 0)
      flag = 2;
  }
  if (sum < ans) {
    ans = sum;
    flag = 2;
    for (i = 0; i < vec2.size(); i++) {
      long long int node = vec2[i];
      ans2[node] = flag;
      if (flag == 2)
        flag = 1;
      else if (flag == 1)
        flag = 0;
      else if (flag == 0)
        flag = 2;
    }
  }
  cout << ans << "\n";
  for (i = 1; i <= n; i++) {
    cout << ans2[i] + 1 << " ";
  }
}
