Merge Strings

4.1

16 votes
Easy-Medium, KMP Algorithm
Problem

Here is your task. You are given two strings and you have to merge/compress them in single string with minimum length such that both strings can be found (one at a time) by breaking that merged string into two parts.
NOTE: String s2 should follow string s1.

INPUT

First line contain number of test cases T. Each test case contains two strings s1 and s2.

OUTPUT

Print merged string.

Constraints

1<=T<=100
1<=length of strings <=10^6

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?