Easy

22.59%

You are given a array of string followed by two words. You have to find the minimum distance between the two words in the given array of string

For example:

(“the”, “quick”, “brown”, “fox”, “quick”)

distance(“fox”,”the”) = 3

distance(“quick”, “fox”) = 1

**Input:**The first line consists of a integer T denoting the number of test cases .Each test case consists of three lines .First line consists of an integer N denoting the size of array of strings .Second line consists of N spaced strings made of 'a' to 'z' .Third line consists of two spaced strings s1,s2 for which you have two find minimum distance.

**Output:**The output consists of a single line for each testcase which is the minimum distance between the two given strings.

**Constraints:**

1<=T<=1000

1<=N<=100

1<=size of strings of array<=100

It is given that s1 and s2 will always be present in the array

**Example:**

**Input:**

1

5

the quick brown fox quick

fox the

**Output:**

3

**Expected time complexity**

O(n)