{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003cp\u003e\u003cfont size \u003d 2\u003e\u003c/font\u003e\u003c/p\u003e\n\u003cp\u003eYou are given two strings \u003cb\u003eA \u003c/b\u003e and \u003cb\u003eB\u003c/b\u003e. Find the number of distinct strings which appear in both \u003cb\u003eA \u003c/b\u003e and \u003cb\u003e B \u003c/b\u003e. A string \u003cb\u003es\u003c/b\u003e is said to appear in \u003cb\u003eS\u003c/b\u003e iff \u003cb\u003es\u003c/b\u003e is a substring (appears contiguously) of \u003cb\u003eS\u003c/b\u003e.\n\u003c/p\u003e\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\nThe first line of the input contains an integer \u003cb\u003eT\u003c/b\u003e denoting the number of test cases. The description of \u003cb\u003eT\u003c/b\u003e test cases follows.\n\u003c/li\u003e\n\u003cli\u003e\nEach test case consists of two lines.\n\u003c/li\u003e\n\u003cli\u003e\nThe first line contains two space separated integers \u003cb\u003e n1 \u003c/b\u003e and \u003cb\u003e n2 \u003c/b\u003e denoting the lengths of \u003cb\u003e A \u003c/b\u003e and \u003cb\u003e B\u003c/b\u003e.\n\u003c/li\u003e\n\u003cli\u003e\nThe second line contains two space separated strings \u003cb\u003eA\u003c/b\u003e and \u003cb\u003eB\u003c/b\u003e.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\nFor each test case output a single number denoting the number of distinct strings appearing in \u003cb\u003eA\u003c/b\u003e and \u003cb\u003e B \u003c/b\u003e.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3\u003eConstraints\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1\u003c/b\u003e ≤ \u003cb\u003eT\u003c/b\u003e ≤ \u003cb\u003e 10\u003csup\u003e4 \u003c/sup\u003e \u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e 1 \u003c/b\u003e ≤ \u003cb\u003en1, n2 \u003c/b\u003e ≤ \u003cb\u003e 10\u003csup\u003e5\u003c/sup\u003e \u003c/b\u003e \u003c/li\u003e\n\u003cli\u003e\u003cb\u003e Sum \u003c/b\u003e of \u003cb\u003en1 + n2 \u003c/b\u003e over \u003cb\u003e all test cases \u003c/b\u003e ≤ \u003cb\u003e 10\u003csup\u003e5\u003c/sup\u003e \u003c/b\u003e \u003c/li\u003e\n\u003cli\u003e\n\u003cb\u003eA\u003c/b\u003e is a string consisting of \u003cb\u003en1\u003c/b\u003e lowercase characters \u003cb\u003e(\u0027a\u0027-\u0027z\u0027)\u003c/b\u003e.\n\u003c/li\u003e\n\u003cli\u003e\n\u003cb\u003eB\u003c/b\u003e is a string consisting of \u003cb\u003en2\u003c/b\u003e lowercase characters \u003cb\u003e(\u0027a\u0027-\u0027z\u0027)\u003c/b\u003e.\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3\u003eExample\u003c/h3\u003e\n\u003cpre\u003e\u003cb\u003eInput:\u003c/b\u003e\n2\n3 5\naad zaacd\n4 4\nabcd lmno\n\u003cb\u003eOutput:\u003c/b\u003e\n3\n0\n\u003c/pre\u003e\u003ch3\u003eExplanation\u003c/h3\u003e\n\u003cp\u003e\n\u003cb\u003eExample case 1.\u003c/b\u003e The three strings are \"a\", \"d\", \"aa\". \u003c/p\u003e\n\u003cp\u003e\n\u003cb\u003eExample case 2.\u003c/b\u003e There are no strings that appear in both A and B.\n\u003c/p\u003e\n"}}]}