#include <bits/stdc++.h>
using namespace std;
const int sieve_size = 15000002;
bool sieve[sieve_size + 1];
vector<long long> prime;
void Sieve() {
  prime.push_back(2);
  for (int i = 3; i * i <= sieve_size; i += 2) {
    if (!sieve[i]) {
      long long p = i * 2;
      for (int j = i * i; j <= sieve_size; j += p) {
        sieve[j] = true;
      }
    }
  }
  for (int i = 3; i <= sieve_size; i += 2) {
    if (!sieve[i]) prime.push_back(i);
  }
}
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
inline int GA(long long n, vector<long long>& vec) {
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    vec.push_back(x);
  }
  return 0;
}
inline int GAEG(long long m, vector<long long> vec[]) {
  for (int i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  return 0;
}
const long long MD = (long long)1000000007;
;
bool isvalid(long long xx, long long yy, long long n, long long m) {
  return (xx >= 0 && xx < n && yy >= 0 && yy < m);
}
long long pw(long long x, long long y, long long dr) {
  if (y == 0) return 1;
  long long o = y / 2;
  long long f = pw(x, o, dr) % dr;
  if (y % 2) {
    return (((f * f) % dr) * x) % dr;
  } else
    return (f * f) % dr;
}
vector<long long> v[100006];
vector<long long> c[3];
vector<long long> anst;
long long mx = 1ll << 61;
long long col[100006];
long long colt[100006];
long long n;
long long DD(long long x, long long p, long long s, long long nm) {
  if (nm == n) {
    if (mx > s) {
      mx = s;
      for (int i = 0; i < n; ++i) colt[i] = col[i];
    }
    return 0;
  }
  for (auto i : v[x]) {
    if (i != p) {
      for (int j = 0; j < 3; ++j) {
        if ((p == -1 && col[x] != j) || (col[p] != j && col[x] != j)) {
          col[i] = j;
          DD(i, x, s + c[j][i], nm + 1);
        }
      }
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < n; ++j) {
      long long x;
      cin >> x;
      c[i].push_back(x);
    }
  }
  long long st = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    v[x].push_back(y);
    v[y].push_back(x);
    if (v[x].size() > 2 || v[y].size() > 2) {
      return cout << -1 << endl, 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (v[i].size() == 1) {
      st = i;
      break;
    }
  }
  for (int i = 0; i < 3; ++i) {
    col[st] = i;
    DD(st, -1, c[i][st], 1);
  }
  cout << mx << endl;
  for (int i = 0; i < n; ++i) cout << colt[i] + 1 << " ";
  return 0;
}
