#include <bits/stdc++.h>
using namespace std;
vector<long long> a[100003];
long long cost[100003][4];
long long color[100003];
long long k1, k2, k3, s;
void dfs(int x, int y, int clr) {
  if (a[y].size() == 1) {
    if (clr == k1) {
      s += cost[y][k2];
      return;
    }
    if (clr == k2) {
      s += cost[y][k3];
      return;
    }
    if (clr == k3) {
      s += cost[y][k1];
      return;
    }
  }
  if (a[y][0] == x) {
    if (clr == k1) {
      s = s + cost[y][k2];
      dfs(y, a[y][1], k2);
    } else if (clr == k2) {
      s = s + cost[y][k3];
      dfs(y, a[y][1], k3);
    } else {
      s = s + cost[y][k1];
      dfs(y, a[y][1], k1);
    }
  } else {
    if (clr == k1) {
      s = s + cost[y][k2];
      dfs(y, a[y][0], k2);
    } else if (clr == k2) {
      s = s + cost[y][k3];
      dfs(y, a[y][0], k3);
    } else {
      s = s + cost[y][k1];
      dfs(y, a[y][0], k1);
    }
  }
}
void dfs1(int x, int y, int clr) {
  color[x] = clr;
  if (a[y].size() == 1) {
    if (clr == k1) {
      color[y] = k2;
      return;
    }
    if (clr == k2) {
      color[y] = k3;
      return;
    }
    if (clr == k3) {
      color[y] = k1;
      return;
    }
  }
  if (a[y][0] == x) {
    if (clr == k1) {
      dfs1(y, a[y][1], k2);
    } else if (clr == k2) {
      dfs1(y, a[y][1], k3);
    } else {
      dfs1(y, a[y][1], k1);
    }
  } else {
    if (clr == k1) {
      dfs1(y, a[y][0], k2);
    } else if (clr == k2) {
      dfs1(y, a[y][0], k3);
    } else {
      dfs1(y, a[y][0], k1);
    }
  }
}
int main() {
  long long n, i, st, fn;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> cost[i][1];
  }
  for (i = 1; i <= n; i++) {
    cin >> cost[i][2];
  }
  for (i = 1; i <= n; i++) {
    cin >> cost[i][3];
  }
  bool f = false;
  for (i = 1; i < n; i++) {
    cin >> st >> fn;
    a[st].push_back(fn);
    a[fn].push_back(st);
    if (a[st].size() > 2 || a[fn].size() > 2) f = true;
  }
  if (f) {
    cout << -1 << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    if (a[i].size() == 1) {
      st = i;
      break;
    }
  }
  long long mn;
  int tt[4];
  k1 = 1;
  k2 = 2;
  k3 = 3;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  mn = s;
  tt[1] = 1;
  tt[2] = 2;
  tt[3] = 3;
  k1 = 1;
  k2 = 3;
  k3 = 2;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  if (mn > s) mn = s, tt[1] = 1, tt[2] = 3, tt[3] = 2;
  k1 = 2;
  k2 = 1;
  k3 = 3;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  if (mn > s) mn = s, tt[1] = 2, tt[2] = 1, tt[3] = 3;
  k1 = 2;
  k2 = 3;
  k3 = 1;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  if (mn > s) mn = s, tt[1] = 2, tt[2] = 3, tt[3] = 1;
  k1 = 3;
  k2 = 1;
  k3 = 2;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  if (mn > s) mn = s, tt[1] = 3, tt[2] = 1, tt[3] = 2;
  k1 = 3;
  k2 = 2;
  k3 = 1;
  s = cost[st][k1];
  dfs(st, a[st][0], k1);
  if (mn > s) mn = s, tt[1] = 3, tt[2] = 2, tt[3] = 1;
  cout << mn << endl;
  k1 = tt[1];
  k2 = tt[2];
  k3 = tt[3];
  dfs1(st, a[st][0], tt[1]);
  for (i = 1; i <= n; i++) {
    cout << color[i] << " ";
  }
  return 0;
}
