{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"![Factors and Multiples][1]\n\nYou will be given two sets of integers. Let\u0027s call them set **A** and set **B**. Set **A** contains **n** elements and set **B** contains **m** elements. You have to remove **k\u003csub\u003e1\u003c/sub\u003e** elements from set **A** and **k\u003csub\u003e2\u003c/sub\u003e** elements from set **B** so that of the remaining values, no integer in set **B** is a multiple of any integer in set **A**. **k\u003csub\u003e1\u003c/sub\u003e** should be in the range **[0, n]** and **k\u003csub\u003e2\u003c/sub\u003e** in the range **[0, m]**.\n\nYou have to find the value of **(k\u003csub\u003e1\u003c/sub\u003e + k\u003csub\u003e2\u003c/sub\u003e)** such that **(k\u003csub\u003e1\u003c/sub\u003e + k\u003csub\u003e2\u003c/sub\u003e)** is as small as possible. **P** is a multiple of **Q** if there is some integer **K** such that **P** \u003d **K * Q**.\n\nSuppose set **A** is `{2, 3, 4, 5}` and set **B** is `{6, 7, 8, 9}`. By removing `{2, 3}` from **A** and `{8}` from B, we get the sets `{4, 5}` and `{6, 7, 9}`. Here none of the integers **6, 7** or **9** is a multiple of **4** or **5**.\n\nSo for this case, the answer is **3** (**two** from set **A** and **one** from set **B**).\n\n[1]: https://static.lightoj.com/images/problem-1149/factors-1604741968435.gif?style\u003drightme,haveborder"}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 50)**, denoting the number of test cases.\n\nThe first line of each case starts with an integer **n** followed by **n** positive integers. The second line starts with **m** followed by **m** positive integers. Both **n** and **m** will be in the range **[1, 100]**. Each element of the two sets will fit in a **32** bit signed integer."}},{"title":"Output","value":{"format":"MD","content":"For each case of input, print the case number and the result."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n4 2 3 4 5\n4 6 7 8 9\n3 100 200 300\n1 150\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 3\nCase 2: 0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}