#include <bits/stdc++.h>
using namespace std;
long long t;
const long long M = 1e9 + 7;
const long long inf = INT64_MAX;
long long factt(long long n) {
  long long ans = 1;
  for (long long i = 1; i <= n; i++) {
    ans *= i;
    ans = ans % M;
  }
  return ans;
}
long long max(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
long long fspow(long long x, long long y) {
  long long ans;
  if (y == 0) return 1;
  ans = fspow(x, y / 2);
  if (y % 2 == 0) return ((ans * ans) % M);
  return (x * ((ans * ans) % M)) % M;
}
long long gcd(long long x, long long y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(x % y, y);
}
long long p2(long long x) {
  long long ans = 0;
  while (x >= 1) {
    ans++;
    x /= 2;
  }
  return ans;
}
pair<long long, vector<long long> > fnans(string s, long long r[],
                                          long long g[], long long b[],
                                          vector<long long>& pm) {
  long long n = pm.size();
  for (long long i = 3; i < n; i++) s.push_back(s[i - 3]);
  long long ans = 0;
  vector<long long> v(n);
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'r') {
      ans += r[pm[i]];
      v[pm[i]] = 1;
    }
    if (s[i] == 'g') {
      ans += g[pm[i]];
      v[pm[i]] = 2;
    }
    if (s[i] == 'b') {
      ans += b[pm[i]];
      v[pm[i]] = 3;
    }
  }
  return {ans, v};
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long r[n], g[n], b[n];
    for (long long i = 0; i < n; i++) cin >> r[i];
    for (long long i = 0; i < n; i++) cin >> g[i];
    for (long long i = 0; i < n; i++) cin >> b[i];
    vector<long long> grp[n];
    for (long long i = 0; i < n - 1; i++) {
      long long u, v;
      cin >> u >> v;
      u--;
      v--;
      grp[u].push_back(v);
      grp[v].push_back(u);
    }
    for (long long i = 0; i < n; i++) {
      if (grp[i].size() > 2) {
        cout << -1 << "\n";
        return 0;
      }
    }
    long long fn = -1;
    for (long long i = 0; i < n; i++) {
      if (grp[i].size() == 1) {
        fn = i;
        break;
      }
    }
    long long p = -1;
    vector<long long> pm;
    while (1) {
      pm.push_back(fn);
      if (grp[fn][0] != p) {
        p = fn;
        fn = grp[fn][0];
        continue;
      }
      if (grp[fn].size() == 1) break;
      if (grp[fn][1] != p) {
        p = fn;
        fn = grp[fn][1];
        continue;
      }
    }
    string a[6] = {"rgb", "rbg", "grb", "gbr", "brg", "bgr"};
    pair<long long, vector<long long> > m1 = {inf, {1, 2, 3}};
    for (long long i = 0; i < 6; i++) {
      pair<long long, vector<long long> > cur = fnans(a[i], r, g, b, pm);
      if (cur.first < m1.first) m1 = cur;
    }
    cout << m1.first << "\n";
    for (long long i = 0; i < n; i++) cout << m1.second[i] << " ";
    cout << "\n";
  }
}
