Universal Cup Judging System

Universal Cup

Süre Sınırı: 2.0 s Bellek Sınırı: 1024 MB Toplam puan: 100 Hack'lenebilir ✓
İstatistikler

Anda diberikan $N$ buah string $S_1, \dots, S_N$, yang masing-masing terdiri dari huruf kecil bahasa Inggris dan memiliki panjang $M$.

Mulanya, misalkan $X = S_1$, lalu lakukan operasi berikut sebanyak $N - 1$ kali.

Pada operasi ke-$i$, misalkan $Y$ adalah string yang dibentuk dengan menggabungkan $X$ dan $S_{i+1}$ sesuai urutan tersebut. Kemudian, pilih sembarang substring berurutan dari $Y$ yang memiliki panjang $M$, dan ganti $X$ dengan substring tersebut.

Keluarkan string terkecil secara leksikografis yang mungkin menjadi nilai akhir dari $X$.

Input

Baris pertama berisi bilangan bulat $N, M$ sesuai urutan tersebut. ($2 \le N \le 2000, 1 \le M \le 2000$)

Masing-masing dari $N$ baris berikutnya berisi sebuah string $S_i$ dengan panjang $M$, yang terdiri dari huruf kecil bahasa Inggris.

Output

Cetak jawabannya.

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

Pada contoh pertama, mulanya $X = \texttt{cat}$. Pada operasi pertama, $Y = \texttt{catcut}$. Jika kita memilih substring berurutan dari karakter ke-$2$ hingga karakter ke-$4$, maka $X = \texttt{atc}$, yang merupakan string terkecil secara leksikografis yang mungkin.

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.