#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long N = 1e6 + 7;
long long mod = 1e9 + 7;
const long long maxn = 2e5 + 7;
const long long INF = 1e16;
vector<long long> adj[maxn];
vector<long long> v(N, 0);
long long c1[N], c2[N], c3[N];
long long b = 0, g = 1, r = 2;
long long sum = 0;
long long counter = 0;
void dfs(long long u, long long p) {
  if (counter % 3 == b) {
    sum += c1[u];
    v[u] = 1;
  } else if (counter % 3 == g) {
    sum += c2[u];
    v[u] = 2;
  } else {
    sum += c3[u];
    v[u] = 3;
  }
  counter++;
  for (auto it : adj[u]) {
    if (it != p) {
      dfs(it, u);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> c1[i];
  for (long long i = 1; i <= n; ++i) cin >> c2[i];
  for (long long i = 1; i <= n; ++i) cin >> c3[i];
  for (long long i = 0; i < n - 1; i++) {
    long long v, u;
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  long long flag = 0;
  long long val;
  for (long long i = 1; i <= n; ++i) {
    if (adj[i].size() > 2) {
      cout << "-1" << '\n';
      flag = 1;
      break;
    } else {
      if (adj[i].size() == 1) val = i;
    }
  }
  if (flag == 0) {
    long long mini = 1e15;
    vector<long long> vec(N, 0);
    for (long long i = 0; i < 6; ++i) {
      sum = 0;
      counter = 0;
      if (i == 3) {
        b = 0;
        g = 2;
        r = 1;
      }
      dfs(val, -1);
      if (sum < mini) {
        mini = sum;
        for (long long i = 1; i <= n; ++i) {
          vec[i] = v[i];
        }
      }
      long long temp = b;
      b = g;
      g = r;
      r = temp;
    }
    cout << mini << '\n';
    for (long long i = 1; i <= n; ++i) {
      cout << vec[i] << " ";
    }
    cout << '\n';
  }
}
