cswork / OAOpen practice workspace

UberOA #41

Generate Array

EasyJudge-ready

Topics (AI-labelled)Strings

Given a string array words, return an array of the same length: item i is the first letter of words[i] concatenated with the last letter of the next word words[i+1]. The next word of the last item is words[0].

Input

The first line contains n; the second line contains n space-separated words. 1≤n≤100000, and each word has length 1..20 and contains only lowercase English letters.

Output

Output n lines; line i is item i of the result array.

Example 1

Input:

4
cat dog flower bed

Output:

cg
dr
fd
bt

Example 2

Input:

1
ab

Output:

ab

Example 3

Input:

2
ab cd

Output:

ad
cb

Example notes

Example 1: words=["cat","dog","flower","bed"], and the result is cg (c + the g of dog), dr (d + the r of flower), fd (f + the d of bed), bt (b + the t of cat). Example 2: with a single word ab, the next word is itself, so the result is ab. Example 3: ["ab","cd"] gives ad and cb.

Editorial

Loading solution…