func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   vector<int> adj[100001];   vector<int> cost[3];   long long matrix[3][3] = {0};   int tree[100000];   int output[100000] = {0};   void makeTree(int a, int pos) {     tree[pos] = a;     for (auto &i : adj[a]) {       if (pos == 0 || tree[pos - 1] != i) makeTree(i, pos + 1);     }   }   long long calc(int a, int b, int i) {     if (i == n) return 0;     int c = 0 ^ 1 ^ 2 ^ a ^ b;     return cost[c][tree[i] - 1] + calc(b, c, i + 1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < int(3); i++)       for (int j = 0; j < int(n); j++) {         int x;         cin >> x;         cost[i].push_back(x);       }     for (int i = 0; i < int(n - 1); i++) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     int counter = 0;     int lf;     for (int i = 0; i < int(n); i++) {       if (adj[i + 1].size() == 1) {         lf = i + 1;         counter++;       }       if (counter > 2) {         cout <<  -1 ;         return 0;       }     }     makeTree(lf, 0);     long long sml = pow(10, 15);     int x, y;     for (int i = 0; i < int(3); i++) {       for (int j = 0; j < int(3); j++) {         if (i == j) continue;         matrix[i][j] =             cost[i][tree[0] - 1] + cost[j][tree[1] - 1] + calc(i, j, 2);         sml = min(sml, matrix[i][j]);         if (sml == matrix[i][j]) {           x = i;           y = j;         }       }     }     cout << sml <<   n ;     output[tree[0] - 1] = x;     output[tree[1] - 1] = y;     for (int i = 2; i < n; i++) {       int c = 0 ^ 1 ^ 2 ^ x ^ y;       output[tree[i] - 1] = c;       x = y;       y = c;     }     for (int i = 0; i < int(n); i++) cout << output[i] + 1 <<    ;     return 0;   }   