#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long c[3][n + 1];
  for (long long j = 0; j < 3; j++)
    for (long long i = 1; i <= n; i++) {
      cin >> c[j][i];
    }
  vector<long long> e[n + 5];
  for (long long i = 1; i <= n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  long long on, tw;
  on = tw = 0;
  bool f = false;
  long long p, q;
  for (long long i = 1; i <= n; i++) {
    if (e[i].size() == 1) {
      on++;
      p = i;
      q = e[i][0];
    } else if (e[i].size() == 2) {
      tw++;
    } else {
      f = true;
    }
  }
  if (on == 2 && tw == n - 2) {
  } else
    f = true;
  if (f) {
    cout << -1 << endl;
    return 0;
  }
  long long sl = -1, fl = -1;
  long long ans = 1e15, ai, aj;
  for (long long i = 0; i <= 2; i++) {
    for (long long j = 0; j <= 2; j++) {
      if (i != j) {
        sl = i, fl = j;
        long long pp = p, qq = q, cur;
        long long temp = c[i][p] + c[j][q];
        while (true) {
          if (e[qq].size() == 1) {
            break;
          }
          if (e[qq][0] != pp) {
            cur = e[qq][0];
          } else
            cur = e[qq][1];
          for (long long k = 0; k < 3; k++) {
            if (k != sl && k != fl) {
              temp += c[k][cur];
              pp = qq;
              qq = cur;
              sl = fl;
              fl = k;
              break;
            }
          }
        }
        if (ans > temp) {
          ans = temp;
          ai = i;
          aj = j;
        }
      }
    }
  }
  long long col[n + 5];
  cout << ans << endl;
  long long i = ai, j = aj;
  sl = i, fl = j;
  long long pp = p, qq = q, cur;
  col[pp] = i + 1;
  col[qq] = j + 1;
  long long temp = c[i][p] + c[j][q];
  while (true) {
    if (e[qq].size() == 1) {
      break;
    }
    if (e[qq][0] != pp) {
      cur = e[qq][0];
    } else
      cur = e[qq][1];
    for (long long k = 0; k < 3; k++) {
      if (k != sl && k != fl) {
        col[cur] = k + 1;
        pp = qq;
        qq = cur;
        sl = fl;
        fl = k;
        break;
      }
    }
  }
  for (long long i = 1; i <= n; i++) cout << col[i] << ' ';
}
