#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
long long rand_int(long long l, long long r) {
  static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<long long>(l, r)(gen);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e % 2)
    return ((b * power((b) * (b), (e - 1) / 2)));
  else
    return power((b) * (b), e / 2);
}
long long modpower(long long b, long long e, long long q) {
  long long MOD = q;
  if (e == 0) return 1;
  if (e % 2)
    return ((b % MOD) * modpower((b % MOD) * (b % MOD), (e - 1) / 2, q)) % MOD;
  else
    return modpower((b % MOD) * (b % MOD), e / 2, q) % MOD;
}
void dpv(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
}
void dpv(vector<pair<long long, long long> > v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}
void dpv(set<long long> v) {
  for (auto i : v) {
    cout << i << " ";
  }
  cout << endl;
}
long long ceil1(long long x, long long y) {
  long long r = x / y;
  if (x % y == 0) {
    return r;
  } else {
    return r + 1;
  }
}
const long long N = 1e5 + 5;
long long dp[N][3][3];
long long c[N][3];
long long level[N];
long long col[N];
vector<vector<long long> > adj(N);
void dfs(long long x, long long p, long long l) {
  level[x] = l;
  for (auto i : adj[x]) {
    if (i != p) {
      dfs(i, x, l + 1);
    }
  }
}
void dfs1(long long x, long long p = 0) {
  for (auto i : adj[x]) {
    if (i != p) {
      dfs1(i, x);
      if (level[x] >= 2) {
        dp[x][0][1] = dp[i][1][2] + c[x][0];
        dp[x][0][2] = dp[i][2][1] + c[x][0];
        dp[x][1][0] = dp[i][0][2] + c[x][1];
        dp[x][1][2] = dp[i][2][0] + c[x][1];
        dp[x][2][1] = dp[i][1][0] + c[x][2];
        dp[x][2][0] = dp[i][0][1] + c[x][2];
      } else if (level[x] == 1) {
        for (long long j = 0; j < 3; j++) {
          for (long long k = 0; k < 3; k++) {
            if (j != k) {
              dp[x][j][k] = c[x][j] + c[i][k];
            }
          }
        }
      }
    }
  }
}
void dfs2(long long x, long long p, long long xx, long long yy) {
  col[x] = xx;
  for (auto i : adj[x]) {
    if (i != p) {
      dfs2(i, x, yy, 6 - (xx + yy));
    }
  }
}
void oblivious() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> c[i][0];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> c[i][1];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> c[i][2];
  }
  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);
  }
  long long f = 1;
  for (long long i = 1; i <= n; i++) {
    if (((long long)(adj[i]).size()) > 2) {
      cout << "-1" << endl;
      return;
    }
    if (((long long)(adj[i]).size()) == 1) {
      f = i;
    }
  }
  dfs(f, 0, 0);
  long long mx = -1;
  for (long long i = 1; i <= n; i++) {
    mx = max(mx, level[i]);
  }
  for (long long i = 1; i <= n; i++) {
    level[i] = mx - level[i];
  }
  dfs1(f);
  long long ans = 1e18;
  long long xx, yy;
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < 3; j++) {
      if (i != j) {
        if (ans > dp[f][i][j]) {
          ans = min(ans, dp[f][i][j]);
          xx = i;
          yy = j;
        }
      }
    }
  }
  xx++;
  yy++;
  cout << ans << endl;
  dfs2(f, 0, xx, yy);
  for (long long i = 1; i <= n; i++) {
    cout << col[i] << " ";
  }
  cout << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    oblivious();
  }
  return 0;
}
