#include <bits/stdc++.h>
using namespace std;
inline bool scan_d(int &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
const int maxn = 1e5 + 10;
int a[maxn][3];
int q, p, n;
bool flag = false;
int vis[maxn], jia[maxn], vv[maxn];
vector<int> g[maxn];
void dfs(int n, int k) {
  if (vis[n] || flag) {
    return;
  }
  int l = g[n].size();
  jia[n] = k;
  vis[n] = 1;
  for (int i = 0; i < l; i++) {
    if (jia[g[n][i]] == -1) {
      jia[g[n][i]] = (jia[n] + 1) % 3;
      dfs(g[n][i], (k + 1) % 3);
    } else if (jia[g[n][i]] == k) {
      flag = true;
      return;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[j][i]);
      vis[j] = 0;
      jia[j] = -1;
      vv[j] = 0;
    }
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &q, &p);
    q--;
    p--;
    g[q].push_back(p);
    g[p].push_back(q);
    vv[p]++;
    vv[q]++;
  }
  int tou = -1;
  for (int i = 0; i < n; i++) {
    if (vv[i] > 2) {
      printf("-1\n");
      return 0;
    }
    if (vv[i] == 1 && tou == -1) {
      tou = i;
    }
  }
  dfs(tou, 0);
  if (flag) {
    printf("-1\n");
    return 0;
  }
  long long sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0, sum6 = 0;
  for (int i = 0; i < n; i++) {
    if (jia[i] == 0) {
      sum1 += (long long)a[i][0];
      sum2 += (long long)a[i][1];
      sum3 += (long long)a[i][2];
      sum4 += (long long)a[i][0];
      sum5 += (long long)a[i][1];
      sum6 += (long long)a[i][2];
    } else if (jia[i] == 1) {
      sum1 += (long long)a[i][1];
      sum2 += (long long)a[i][2];
      sum3 += (long long)a[i][0];
      sum4 += (long long)a[i][2];
      sum5 += (long long)a[i][0];
      sum6 += (long long)a[i][1];
    } else if (jia[i] == 2) {
      sum1 += (long long)a[i][2];
      sum2 += (long long)a[i][0];
      sum3 += (long long)a[i][1];
      sum4 += (long long)a[i][1];
      sum5 += (long long)a[i][2];
      sum6 += (long long)a[i][0];
    }
  }
  long long mi = min(min(min(sum1, sum4), min(sum2, sum3)), min(sum5, sum6));
  printf("%lld\n", mi);
  if (mi == sum1) {
    for (int i = 0; i < n; i++) {
      printf(i == n - 1 ? "%d\n" : "%d ", jia[i] + 1);
    }
  } else if (mi == sum2) {
    for (int i = 0; i < n; i++) {
      printf(i == n - 1 ? "%d\n" : "%d ", (jia[i] + 1) % 3 + 1);
    }
  } else if (mi == sum3) {
    for (int i = 0; i < n; i++) {
      printf(i == n - 1 ? "%d\n" : "%d ", (jia[i] + 2) % 3 + 1);
    }
  } else if (mi == sum4) {
    for (int i = 0; i < n; i++) {
      int kk = (4 - jia[i]) % 3;
      if (kk == 0) {
        kk = 3;
      }
      printf(i == n - 1 ? "%d\n" : "%d ", kk);
    }
  } else if (mi == sum5) {
    for (int i = 0; i < n; i++) {
      int kk = (5 - jia[i]) % 3;
      if (kk == 0) {
        kk = 3;
      }
      printf(i == n - 1 ? "%d\n" : "%d ", kk);
    }
  } else if (mi == sum6) {
    for (int i = 0; i < n; i++) {
      int kk;
      if (jia[i] == 1) {
        kk = 2;
      } else if (jia[i] == 0) {
        kk = 3;
      } else if (jia[i] == 2) {
        kk = 1;
      }
      printf(i == n - 1 ? "%d\n" : "%d ", kk);
    }
  }
  return 0;
}
