#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long n, a[3][100007], cl[100007], resCl[100007], sum, cur, mn;
pair<long long, long long> x, res;
vector<long int> g[100007];
void dfs(long int v, long int pa) {
  for (auto i : g[v]) {
    if (i == pa) continue;
    sum += a[3 - cl[v] - cl[pa]][i];
    cl[i] = 3 - cl[v] - cl[pa];
    dfs(i, v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long int j = 0; j < 3; j++)
    for (long int i = 0; i < n; i++) {
      cin >> a[j][i];
    }
  for (long int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    g[--v].push_back(--u);
    g[u].push_back(v);
    if (g[v].size() > 2 || g[u].size() > 2) {
      cout << -1;
      return 0;
    }
  }
  for (long int i = 0; i < n; i++)
    if (g[i].size() == 1) {
      x.first = i;
      break;
    }
  x.second = g[x.first][0];
  mn = 1e16;
  for (long int i = 0; i < 3; i++) {
    for (long int j = 0; j < 3; j++) {
      if (i == j) continue;
      cl[x.first] = i;
      cl[x.second] = j;
      sum = a[i][x.first] + a[j][x.second];
      dfs(x.second, x.first);
      if (sum < mn) {
        res.first = i;
        res.second = j;
        mn = sum;
        for (long int i = 0; i < n; i++) resCl[i] = cl[i];
      }
    }
  }
  cout << mn << "\n";
  for (long int i = 0; i < n; i++) cout << resCl[i] + 1 << " ";
}
