There are multiple test cases. The first line of the input contains an integerindicating the number of test cases. For each test case:
The first line contains two integersand
(
,
) indicating the number of vertices and edges.
The second line containsintegers
(
) where
indicates the limit of the
-th vertex.
For the followinglines, the
-th line contains two integers
and
(
) indicating that there is an edge connecting vertex
and
. Note that there might be self loops or multiple edges.
It's guaranteed that neither the sum ofnor the sum of
of all test cases will exceed
.
For each test case output two lines. The first line contains an integer indicating the smallest possible. The second line contains a string
of length
consisting only of `0's and `1's indicating a direction assignment plan of the edges to achieve the smallest possible
. If
then the i-th edge is going from
into
; Otherwise it's going from
into
. If there are multiple valid answers you can output any of them.