#include <bits/stdc++.h>
using namespace std;
void SieveOfEratosthenes(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
long long power(long long x, long long y, long long m) {
  if (y == 0) return 1;
  long long p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
void print(vector<long long> a) {
  for (long long i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << "\n";
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool cmp(long long a, long long b) { return a > b; }
vector<vector<long long> > adj(1e5 + 1);
vector<vector<long long> > cs(3, vector<long long>(1e5 + 1));
long long dfs(long long x, long long p, long long cl, long long pcl,
              vector<long long>& tp) {
  long long c = 0;
  for (auto k : adj[x]) {
    if (k == p || tp[k - 1] != -1) continue;
    c += cs[cl - 1][k - 1];
    tp[k - 1] = cl;
    c += dfs(k, x, 6 - cl - pcl, cl, tp);
  }
  return c;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long cx[6] = {1, 2, 3, 1, 2, 3};
  long long d[6] = {2, 3, 1, 3, 1, 2};
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> cs[i][j];
    }
  }
  vector<pair<long long, long long> > edges(n - 1);
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    edges[i] = {x, y};
  }
  bool f = true;
  long long h;
  for (long long i = 0; i < n; i++) {
    if (adj[i + 1].size() > 2) {
      f = false;
      break;
    } else if (adj[i + 1].size() == 1) {
      h = i + 1;
    }
  }
  if (!f) {
    cout << -1;
  } else {
    long long ans = 1e18;
    vector<long long> sol(n);
    long long x = h, y = adj[h][0];
    for (long long j = 0; j < 6; j++) {
      long long c = 0;
      vector<long long> tp(n, -1);
      c += cs[cx[j] - 1][x - 1];
      c += cs[d[j] - 1][y - 1];
      x--, y--;
      tp[x] = cx[j], tp[y] = d[j];
      x++, y++;
      c += dfs(x, y, 6 - cx[j] - d[j], cx[j], tp);
      c += dfs(y, x, 6 - d[j] - cx[j], d[j], tp);
      if (c < ans) {
        if (c == 3) {
          cout << x << " " << y << j;
        }
        ans = c;
        sol = tp;
      }
    }
    cout << ans << "\n";
    print(sol);
  }
}
