#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
vector<long long> adj[300010], par(300010, -1), vis(300010, 0);
vector<long long> order;
void dfs(int a) {
  vis[a] = 1;
  order.push_back(a);
  for (auto i : adj[a]) {
    if (vis[i] == 0) dfs(i);
  }
}
int myrandom(int i) { return std::rand() % i; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<vector<long long>> cost(3, vector<long long>(n + 1, 0));
  for (int i = 1; i <= n; i++) {
    cin >> cost[0][i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> cost[1][i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> cost[2][i];
  }
  vector<int> in(n + 1, 0);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    in[a]++;
    in[b]++;
  }
  int leaf = -1;
  for (int i = 1; i <= n; i++) {
    if (in[i] > 2) {
      cout << -1 << '\n';
      return 0;
    }
    if (in[i] == 1) {
      leaf = i;
    }
  }
  dfs(leaf);
  vector<int> per = {0, 1, 2};
  long long mini = 1ll << 50;
  do {
    long long price = 0;
    for (int i = 0; i < order.size(); i++) {
      price = price + cost[per[i % 3]][order[i]];
    }
    mini = min(mini, price);
  } while (next_permutation((per).begin(), (per).end()));
  per = {0, 1, 2};
  vector<int> col(n + 1, 0);
  do {
    long long price = 0;
    for (int i = 0; i < order.size(); i++) {
      price = price + cost[per[i % 3]][order[i]];
    }
    if (price == mini) {
      cout << mini << '\n';
      for (int i = 0; i < order.size(); i++) {
        col[order[i]] = per[i % 3] + 1;
      }
      for (int i = 1; i <= n; i++) {
        cout << col[i] << " ";
      }
      cout << '\n';
      return 0;
    }
  } while (next_permutation((per).begin(), (per).end()));
  cout << mini << '\n';
}
