{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"(人工翻译所以可能有偏误,建议自己用机翻再翻译一遍)有多个家庭要一起去一个超市买东西,超市内的每件物品都只能买一件,每个人能承受的重量有限,问在重量限制内,最多能买总价值为多少的物品。"}},{"title":"Input","value":{"format":"MD","content":"第一行输入一个T,表示有T组测试用例。\n\n接下来每组测试用例第一行输入一个N,表示这个超市有多少物品。\n接下来输入N行,每行包括两个整数P(1\u003c\u003dP\u003c\u003d100)和W(1\u003c\u003dW\u003c\u003d30),整数P表示第i个物品的价值,W表示该物品的重量。\n然后再输入一个整数G(1\u003c\u003dG\u003c\u003d100),表示这个家庭有多少人。\n最后输入G行,每行一个整数M((1\u003c\u003dMW\u003c\u003d30)),表示每个家庭成员的最大重量承受值。"}},{"title":"Output","value":{"format":"MD","content":"输出T行,每行一个整数表示该家庭所有成员可以购买的物品的最大总价值的总和。"}},{"title":"Sample Input","value":{"format":"MD","content":"\u003cpre\u003e\n2\n3\n72 17\n44 23\n31 24\n1\n26\n6\n64 26\n85 22\n52 4\n99 18\n39 13\n54 9\n4\n23\n20\n20\n26\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"MD","content":"\u003cpre\u003e\n72\n514\u003c/pre\u003e"}}]}