#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int MAX_LOG = 21;
const int MAX_N = 100005;
long long cost[3][MAX_N];
vector<int> edges[MAX_N];
long long dp[3][3][MAX_N];
vector<int> line;
void dfsFindLine(int node, int parent) {
  for (int child : edges[node]) {
    if (child != parent) {
      line.push_back(child);
      dfsFindLine(child, node);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int color = 0; color < 3; color++) {
    for (int i = 1; i <= n; i++) {
      cin >> cost[color][i];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  int root = 1;
  for (int i = 1; i <= n; i++) {
    if (edges[i].size() >= 3) {
      cout << -1 << endl;
      return 0;
    }
    if (edges[i].size() == 1) {
      root = i;
    }
  }
  line.push_back(root);
  dfsFindLine(root, root);
  for (int c1 = 0; c1 < 3; c1++) {
    for (int c2 = 0; c2 < 3; c2++) {
      if (c1 != c2) {
        dp[c1][c2][line[n - 2]] = cost[c1][line[n - 2]] + cost[c2][line[n - 1]];
      }
    }
  }
  for (int i = n - 3; i >= 0; i--) {
    for (int c1 = 0; c1 < 3; c1++) {
      for (int c2 = 0; c2 < 3; c2++) {
        for (int c3 = 0; c3 < 3; c3++) {
          if (c1 != c2 && c2 != c3 && c1 != c3) {
            dp[c1][c2][line[i]] = cost[c1][line[i]] + dp[c2][c3][line[i + 1]];
          }
        }
      }
    }
  }
  long long mini = INF;
  int color1, color2;
  for (int c1 = 0; c1 < 3; c1++) {
    for (int c2 = 0; c2 < 3; c2++) {
      if (c1 != c2) {
        long long temp = dp[c1][c2][line[0]];
        if (temp < mini) {
          color1 = c1;
          color2 = c2;
          mini = temp;
        }
      }
    }
  }
  cout << mini << endl;
  int color[MAX_N];
  color[line[0]] = color1 + 1;
  color[line[1]] = color2 + 1;
  for (int i = 2; i < n; i++) {
    for (int c = 0; c < 3; c++) {
      if (c != color1 && c != color2) {
        color[line[i]] = c + 1;
        color1 = color2;
        color2 = c;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << color[i] << " ";
  }
}
