#C3593. Concatenation of Two Different Strings
Concatenation of Two Different Strings
Concatenation of Two Different Strings
You are given an integer n, a list of n strings, and a target string. Your task is to determine whether the target string can be formed by concatenating exactly two different strings from the given list.
Formally, given a list S={s1, s2, ..., sn} and a target string T, check if there exists two distinct indices i and j (i ≠ j) such that T = si + sj, where + denotes concatenation.
Note: The two strings chosen must be different as complete strings (i.e. they must not be identical even if they appear more than once in the list).
inputFormat
The input is read from stdin and consists of three parts:
- The first line contains an integer n, the number of strings in the list.
- The second line contains n space-separated strings.
- The third line contains the target string T.
outputFormat
Output a single line to stdout containing either "POSSIBLE" if the target string can be formed by concatenating exactly two different strings from the list, or "IMPOSSIBLE" otherwise.
## sample3
hello world day
helloworld
POSSIBLE