#include <bits/stdc++.h>
using namespace std;
vector<long long> v[200005];
long long visit[200005];
long long a[200005];
void dfs(long long node, long long cnt) {
  visit[node] = true;
  a[node] = cnt;
  for (long long i = 0; i < v[node].size(); i++) {
    if (!visit[v[node][i]]) {
      dfs(v[node][i], cnt + 1);
    }
  }
}
int main() {
  long long n;
  cin >> n;
  long long g[4][n + 1];
  for (long long j = 0; j < 3; j++) {
    for (long long i = 1; i <= n; i++) {
      cin >> g[j][i];
    }
  }
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int pos;
  for (long long i = 1; i <= n; i++) {
    if (v[i].size() > 2) {
      cout << -1;
      return 0;
    }
    if (v[i].size() == 1) {
      pos = i;
    }
  }
  dfs(pos, 1);
  long long sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0, sum6 = 0;
  vector<long long> v1, v2, v3, v4, v5, v6;
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum1 += (g[0][i]);
      v1.push_back(1);
    } else if ((a[i] - 1) % 3 == 1) {
      sum1 += (g[1][i]);
      v1.push_back(2);
    } else if ((a[i] - 1) % 3 == 2) {
      sum1 += (g[2][i]);
      v1.push_back(3);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum2 += (g[0][i]);
      v2.push_back(1);
    } else if ((a[i] - 1) % 3 == 1) {
      sum2 += (g[2][i]);
      v2.push_back(3);
    } else if ((a[i] - 1) % 3 == 2) {
      sum2 += (g[1][i]);
      v2.push_back(2);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum3 += (g[1][i]);
      v3.push_back(2);
    } else if ((a[i] - 1) % 3 == 1) {
      sum3 += (g[0][i]);
      v3.push_back(1);
    } else if ((a[i] - 1) % 3 == 2) {
      sum3 += (g[2][i]);
      v3.push_back(3);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum4 += (g[1][i]);
      v4.push_back(2);
    } else if ((a[i] - 1) % 3 == 1) {
      sum4 += (g[2][i]);
      v4.push_back(3);
    } else if ((a[i] - 1) % 3 == 2) {
      sum4 += (g[0][i]);
      v4.push_back(1);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum5 += (g[2][i]);
      v5.push_back(3);
    } else if ((a[i] - 1) % 3 == 1) {
      sum5 += (g[0][i]);
      v5.push_back(1);
    } else if ((a[i] - 1) % 3 == 2) {
      sum5 += (g[1][i]);
      v5.push_back(2);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if ((a[i] - 1) % 3 == 0) {
      sum6 += (g[2][i]);
      v6.push_back(3);
    } else if ((a[i] - 1) % 3 == 1) {
      sum6 += (g[1][i]);
      v6.push_back(2);
    } else if ((a[i] - 1) % 3 == 2) {
      sum6 += (g[0][i]);
      v6.push_back(1);
    }
  }
  long long mini = 2 * 1e18;
  vector<long long> ans;
  if (mini > sum1) {
    mini = sum1;
    ans = v1;
  }
  if (mini > sum2) {
    mini = sum2;
    ans = v2;
  }
  if (mini > sum3) {
    mini = sum3;
    ans = v3;
  }
  if (mini > sum4) {
    mini = sum4;
    ans = v4;
  }
  if (mini > sum5) {
    mini = sum5;
    ans = v5;
  }
  if (mini > sum6) {
    mini = sum6;
    ans = v6;
  }
  cout << mini << "\n";
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
