{"raw_statement":[{"iden":"statement","content":"You are given two non-empty strings S and T of equal lengths. S contains the characters 0, 1 and ?, whereas T contains 0 and 1 only. Your task is to convert S into T in minimum number of moves. In each move, you can:\n\n 1. change a 0 in S to 1\n\n2. change a ? in S to 0 or 1\n\n3. swap any two characters in S\n\nAs an example, suppose S = 01??00 and T = 001010. We can transform S into T in 3 moves:\n\n• Initially S = 01??00\n\n• Move 1 – change S[2] to 1. S becomes 011?00\n\n• Move 2 – change S[3] to 0. S becomes 011000\n\n• Move 3 – swap S[1] with S[4]. S becomes 001010\n\n• S is now equal to T\n\nThe first line of input is an integer C (C ≤ 200) that indicates the number of test cases. Each case consists of two lines. The first line is the string S consisting of ‘0’, ‘1’ and ‘?’. The second line is the string T consisting of ‘0’ and ‘1’. The lengths of the strings won’t be larger than 100.\n\nFor each case, output the case number first followed by the minimum number of moves required to convert S into T. If the transition is impossible, output  - 1 instead.\n\n"},{"iden":"input","content":"The first line of input is an integer C (C ≤ 200) that indicates the number of test cases. Each case consists of two lines. The first line is the string S consisting of ‘0’, ‘1’ and ‘?’. The second line is the string T consisting of ‘0’ and ‘1’. The lengths of the strings won’t be larger than 100."},{"iden":"output","content":"For each case, output the case number first followed by the minimum number of moves required to convert S into T. If the transition is impossible, output  - 1 instead."},{"iden":"examples","content":"Input301??000010100110110001000000OutputCase 1: 3Case 2: 1Case 3: -1"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ C \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, C\\} $:  \n- Let $ S_k \\in \\{0, 1, ?\\}^n $ be the source string of length $ n $.  \n- Let $ T_k \\in \\{0, 1\\}^n $ be the target string of length $ n $.  \n\n**Constraints**  \n1. $ 1 \\leq C \\leq 200 $  \n2. $ 1 \\leq n \\leq 100 $  \n3. $ T_k $ contains only characters '0' and '1'.  \n4. $ S_k $ contains characters '0', '1', and '?'.  \n\n**Objective**  \nFind the minimum number of moves to transform $ S_k $ into $ T_k $, where each move is one of:  \n- Change a '0' in $ S_k $ to '1' (cost 1).  \n- Change a '?' in $ S_k $ to '0' or '1' (cost 1).  \n- Swap any two characters in $ S_k $ (cost 1).  \n\nIf transformation is impossible, output $-1$.  \n\n**Impossibility Condition**  \nLet $ z_S $, $ o_S $, $ q_S $ denote the counts of '0', '1', '?' in $ S_k $, and $ z_T $, $ o_T $ the counts of '0', '1' in $ T_k $.  \nTransformation is impossible if:  \n$$\nz_S + q_S < z_T \\quad \\text{or} \\quad o_S + q_S < o_T\n$$\n\nOtherwise, compute the minimum moves.","simple_statement":"You are given two strings S and T of equal length.  \nS contains '0', '1', and '?'  \nT contains only '0' and '1'  \n\nYou can do these moves:  \n- Change '0' to '1'  \n- Change '?' to '0' or '1'  \n- Swap any two characters  \n\nFind the minimum number of moves to turn S into T.  \nIf impossible, return -1.","has_page_source":false}