#include <bits/stdc++.h>
using namespace std;
unsigned long long min(unsigned long long x, unsigned long long y) {
  if (x < y) return x;
  return y;
}
unsigned long long max(unsigned long long x, unsigned long long y) {
  if (x < y) return y;
  return x;
}
long long min(long long x, long long y) {
  if (x < y) return x;
  return y;
}
long long max(long long x, long long y) {
  if (x < y) return y;
  return x;
}
unsigned long long gcd(unsigned long long x, unsigned long long y) {
  if (!x) return y;
  if (!y) return x;
  if (x > y) swap(x, y);
  return gcd(x, y % x);
}
int n, col[100005] = {0};
unsigned long long c[3][100005] = {0};
vector<int> g[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int start = -1, pre = -1, cur = -1, col1 = -1, col2 = -1, prec = -1,
      pprec = -1;
  for (int i = 0; i < n; i++) {
    if (g[i].size() > 2) {
      cout << "-1\n";
      return 0;
    }
    if (g[i].size() == 1) {
      start = i;
    }
  }
  unsigned long long ans = 0xffffffffffffffff, cost;
  for (int c1 = 0; c1 < 3; c1++) {
    for (int c2 = 0; c2 < 3; c2++) {
      if (c1 == c2) continue;
      if (g[g[start][0]][0] != start) {
        cur = g[g[start][0]][0];
      } else {
        cur = g[g[start][0]][1];
      }
      pre = g[start][0];
      cost = c[c1][start] + c[c2][g[start][0]];
      pprec = c1;
      prec = c2;
      while (g[cur].size() > 1) {
        int sum = pprec + prec;
        pprec = prec;
        prec = 3 - sum;
        cost += c[prec][cur];
        if (g[cur][0] != pre) {
          pre = cur;
          cur = g[cur][0];
        } else {
          pre = cur;
          cur = g[cur][1];
        }
      }
      prec = 3 - (pprec + prec);
      cost += c[prec][cur];
      if (cost < ans) {
        ans = cost;
        col1 = c1;
        col2 = c2;
      }
    }
  }
  if (g[g[start][0]][0] != start) {
    cur = g[g[start][0]][0];
  } else {
    cur = g[g[start][0]][1];
  }
  pre = g[start][0];
  pprec = col1;
  prec = col2;
  col[start] = col1;
  col[pre] = prec;
  while (g[cur].size() > 1) {
    int sum = pprec + prec;
    pprec = prec;
    prec = 3 - sum;
    col[cur] = prec;
    if (g[cur][0] != pre) {
      pre = cur;
      cur = g[cur][0];
    } else {
      pre = cur;
      cur = g[cur][1];
    }
  }
  prec = 3 - (pprec + prec);
  col[cur] = prec;
  cout << ans << "\n";
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << col[i] + 1;
  }
  cout << "\n";
  return 0;
}
