------
## 最终结论
```python
def minimum_time_to_send_presents(test_cases):
    results = []
    for n, m, stack, send_list in test_cases:
        position = {value: idx for idx, value in enumerate(stack)}
        max_position = -1
        total_time = 0

        for present in send_list:
            current_position = position[present]
            if current_position > max_position:
                total_time += (current_position - max_position) * 2 + 1
                max_position = current_position
            else:
                total_time += 1

        results.append(total_time)

    return results

# Reading input
t = int(input().strip())
test_cases = []
for _ in range(t):
    n, m = map(int, input().strip().split())
    stack = list(map(int, input().strip().split()))
    send_list = list(map(int, input().strip().split()))
    test_cases.append((n, m, stack, send_list))

# Calculating results
results = minimum_time_to_send_presents(test_cases)

# Printing output
for result in results:
    print(result)
```