#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int c[4][100000 + 10];
long long res;
int degree[100000 + 10];
vector<int> each[100000 + 10];
int n;
vector<int> order;
long long dfs(int now, int las, int laslas) {
  if (now > n) return 0;
  int Is;
  for (int i = 1; i <= 3; ++i) {
    if (i != las && i != laslas) {
      Is = i;
    }
  }
  return (long long)(c[Is][order[now]]) + dfs(now + 1, Is, las);
}
int col[100000 + 10];
void recover(int now, int las, int laslas) {
  if (now > n) return;
  int Is;
  for (int i = 1; i <= 3; ++i) {
    if (i != las && i != laslas) {
      Is = i;
    }
  }
  col[order[now]] = Is;
  recover(now + 1, Is, las);
}
void dfs_put(int now, int las) {
  order.push_back(now);
  if (degree[now] == 1 && las != -1) return;
  for (auto it : each[now]) {
    if (it != las) {
      dfs_put(it, now);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= 3; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &c[i][j]);
  for (int i = 1; i <= n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    each[u].push_back(v);
    each[v].push_back(u);
    degree[u]++;
    degree[v]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (degree[i] >= 3) {
      cout << -1 << endl;
      return 0;
    }
  }
  int root;
  for (int i = 1; i <= n; ++i) {
    if (degree[i] == 1) {
      root = i;
      break;
    }
  }
  order.push_back(1);
  dfs_put(root, -1);
  res = (long long)1000000000 * 2000000;
  long long tmp = 0;
  for (int i = 1; i <= 3; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i == j) continue;
      tmp = c[i][order[1]] + c[j][order[2]];
      tmp += dfs(3, j, i);
      res = min(res, tmp);
    }
  }
  cout << res << endl;
  for (int i = 1; i <= 3; ++i) {
    for (int j = 1; j <= 3; ++j) {
      if (i == j) continue;
      tmp = c[i][order[1]] + c[j][order[2]];
      tmp += dfs(3, j, i);
      if (tmp == res) {
        col[order[1]] = i;
        col[order[2]] = j;
        recover(3, j, i);
        break;
      }
    }
  }
  for (int i = 1; i <= n; ++i) cout << col[i] << " ";
  cout << endl;
  return 0;
}
