There are N cards placed face down in a row. A positive integer less than or equal to m is written on each card.
Let A_i be the integer written on the i-th card.
Your goal is to guess A_1,,A_2,,⋯,,A_N correctly.
The only operation you can do is:
Also, you are given the following information:
What is the minimum cost you need to pay to guess all of A_1,,A_2,,⋯,,A_N correctly?
The first line contains three integers N, M and m.
The second line contains N integers X_1,,X_2,,⋯,,X_N.
This is followed by M lines, the i-th line contains three integers a_i, b_i and c_i.
If the N integers written on each card can't be determined no matter how much you pay(i.e. if there's a contradiction in the information), print only -1.
Otherwise, in the first line, print a single integer — the minimum cost you need to pay to guess all of A_i correctly.
In the second line, print N integers A′_1,,A′_2,,⋯,,A′_N — one of the possibilities of A_1,,A_2,,⋯,,A_N.