Universal Cup Judging System

Universal Cup

実行時間制限: 2.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓
統計

Þér eru gefnir $N$ strengir $S_1, \dots, S_N$, sem hver um sig samanstendur af enskum lágstöfum og hefur lengdina $M$.

Í upphafi, látum $X = S_1$, og framkvæmum eftirfarandi aðgerð $N - 1$ sinnum.

Í $i$-tu aðgerðinni, látum $Y$ vera strenginn sem myndast við að skeyta $X$ og $S_{i+1}$ saman í þessari röð. Veldu síðan hvaða samfellda hlutstreng sem er úr $Y$ af lengd $M$, og skiptu $X$ út fyrir þann hlutstreng.

Prentaðu þann streng sem er fremstur í stafrófsröð og getur mögulega verið lokagildið á $X$.

Input

Fyrsta línan inniheldur heiltölurnar $N, M$ í þessari röð. ($2 \le N \le 2000, 1 \le M \le 2000$)

Hver af næstu $N$ línum inniheldur streng $S_i$ af lengd $M$, sem samanstendur af enskum lágstöfum.

Output

Prentaðu svarið.

Examples

Input 1

2 3
cat
cut

Output 1

atc

Input 2

2 1
a
b

Output 2

a

Input 3

3 8
jastaway
tatesoto
soryuusi

Output 3

asoryuus

Note

Í fyrsta dæminu er í upphafi $X = \texttt{cat}$. Í fyrstu aðgerðinni er $Y = \texttt{catcut}$. Ef við veljum samfellda hlutstrenginn frá $2$-ja til $4$-ða stafs, þá er $X = \texttt{atc}$, sem er fremsti mögulegi strengurinn í stafrófsröð.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1629EditorialOpenO(n^3 log \sum /w) 做法tzl_Dedicatus545View
#1523EditorialOpen题解jianglyView
#1506EditorialOpenO(n^3) 做法incentView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.