#include <bits/stdc++.h>
using namespace std;
long long a[100005][3];
vector<vector<long long> > g(100005);
vector<long long> gg;
void dfs(long long x, long long p) {
  gg.push_back(x);
  for (auto X : g[x]) {
    if (X != p) {
      dfs(X, x);
    }
  }
}
long long count(string s) {
  long long i = 0, ans = 0;
  for (auto X : gg) {
    ans += a[X][s[i] - '0'];
    i++;
    i %= 3;
  }
  return ans;
}
void print(string s) {
  long long int i = 0;
  map<long long, long long> m;
  for (auto X : gg) {
    m[X] = s[i] - '0' + 1;
    i++;
    i %= 3;
  }
  for (long long int i = 1; i <= gg.size(); i++) {
    cout << m[i] << " ";
  }
  cout << "\n";
  exit(0);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, c_1 = 0, c_2 = 0;
  cin >> n;
  for (long long int i = 0; i < 3; i++) {
    for (long long int j = 1; j <= n; j++) {
      cin >> a[j][i];
    }
  }
  for (long long int i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<long long> root;
  for (long long int i = 1; i <= n; i++) {
    c_1 += (g[i].size() == 1);
    if (g[i].size() == 1) root.push_back(i);
    c_2 += (g[i].size() == 2);
  }
  if (c_1 != 2 || c_2 != n - 2) {
    cout << -1;
    return 0;
  }
  dfs(root[0], 0);
  vector<long long> mm;
  long long mmm = LLONG_MAX;
  string s[] = {"012", "021", "102", "120", "201", "210"};
  for (long long int i = 0; i < 6; i++) mm.push_back(count(s[i]));
  for (long long int i = 0; i < 6; i++) mmm = min(mmm, mm[i]);
  for (long long int i = 0; i < 6; i++) {
    if (mm[i] == mmm) {
      cout << mmm << "\n";
      print(s[i]);
    }
  }
}
