#include <bits/stdc++.h>
using namespace std;
const int maxlongint = 2147483647;
const int P1 = 19260817, P2 = 1000000007, N = 100011, M = 1000011;
long long mi1[M], mi2[M], ni1[M], ni2[M], s1[M], s2[M];
char st[M], Ans[M];
long long powder(int x, int a, const int& P) {
  if (!a) return 1;
  long long tot = powder(x, a >> 1, P);
  tot = (tot * tot) % P;
  if (a & 1) tot = (tot * x) % P;
  return tot;
}
inline long long num(char ch) {
  return ('0' <= ch && ch <= '9')
             ? (ch - '0')
             : (('a' <= ch && ch <= 'z') ? (ch - 'a' + 10) : (ch - 'A' + 36));
}
void pre(int n) {
  long long c = 62, nn1 = powder(c, P1 - 2, P1), nn2 = powder(c, P2 - 2, P2);
  if (nn1 * 62 % P1 != 1 || nn2 * 62 % P2 != 1) printf("Sfsf\n");
  mi1[0] = 1;
  for (int i = 1; i <= n; i++) {
    mi1[i] = (mi1[i - 1] * c) % P1;
    if (mi1[i] < 0)
      while (1) mi1[-154151564];
  }
  mi2[0] = 1;
  for (int i = 1; i <= n; i++) {
    mi2[i] = (mi2[i - 1] * c) % P2;
    if (mi2[i] < 0)
      while (1) mi2[-134564522];
  }
  ni1[0] = 1;
  for (int i = 1; i <= n; i++) ni1[i] = ni1[i - 1] * nn1 % P1;
  ni2[0] = 1;
  for (int i = 1; i <= n; i++) ni2[i] = ni2[i - 1] * nn2 % P2;
}
int main() {
  pre(1000000);
  int n;
  scanf("%d", &n);
  int totlen = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", st + 1);
    int l = strlen(st + 1);
    int pos = 0;
    long long c = 62;
    long long sh1 = 0, sh2 = 0;
    for (int j = 1; j <= l && j <= totlen; j++) {
      sh1 = (sh1 * c + num(st[j])) % P1;
      sh2 = (sh2 * c + num(st[j])) % P2;
      if (sh1 < 0 || sh2 < 0)
        while (1) putchar('\n');
      if ((s1[totlen] - s1[totlen - j] * mi1[j] % P1 + P1) % P1 == sh1 &&
          (s2[totlen] - s2[totlen - j] * mi2[j] % P2 + P2) % P2 == sh2)
        pos = j;
    }
    for (int j = pos + 1; j <= l; j++) {
      Ans[++totlen] = st[j];
      s1[totlen] = (s1[totlen - 1] * c + num(Ans[totlen])) % P1;
      s2[totlen] = (s2[totlen - 1] * c + num(Ans[totlen])) % P2;
      if (s1[totlen] * c < 0 || s2[totlen] * c < 0)
        while (1) putchar('\n');
    }
  }
  for (int i = 1; i <= totlen; i++) putchar(Ans[i]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}

### Prompt

Please formulate a Cpp solution to the following problem:

Amugae has a sentence consisting of n words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word that coincides with a suffix of the first word. For example, he merges "sample" and "please" into "samplease".

Amugae will merge his sentence left to right (i.e. first merge the first two words, then merge the result with the third word and so on). Write a program that prints the compressed word after the merging process ends.

Input

The first line contains an integer n (1 ≤ n ≤ 10^5), the number of the words in Amugae's sentence.

The second line contains n words separated by single space. Each words is non-empty and consists of uppercase and lowercase English letters and digits ('A', 'B', ..., 'Z', 'a', 'b', ..., 'z', '0', '1', ..., '9'). The total length of the words does not exceed 10^6.

Output

In the only line output the compressed word after the merging process ends as described in the problem.

Examples

Input


5
I want to order pizza


Output


Iwantorderpizza

Input


5
sample please ease in out


Output


sampleaseinout

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxlongint = 2147483647;
const int P1 = 19260817, P2 = 1000000007, N = 100011, M = 1000011;
long long mi1[M], mi2[M], ni1[M], ni2[M], s1[M], s2[M];
char st[M], Ans[M];
long long powder(int x, int a, const int& P) {
  if (!a) return 1;
  long long tot = powder(x, a >> 1, P);
  tot = (tot * tot) % P;
  if (a & 1) tot = (tot * x) % P;
  return tot;
}
inline long long num(char ch) {
  return ('0' <= ch && ch <= '9')
             ? (ch - '0')
             : (('a' <= ch && ch <= 'z') ? (ch - 'a' + 10) : (ch - 'A' + 36));
}
void pre(int n) {
  long long c = 62, nn1 = powder(c, P1 - 2, P1), nn2 = powder(c, P2 - 2, P2);
  if (nn1 * 62 % P1 != 1 || nn2 * 62 % P2 != 1) printf("Sfsf\n");
  mi1[0] = 1;
  for (int i = 1; i <= n; i++) {
    mi1[i] = (mi1[i - 1] * c) % P1;
    if (mi1[i] < 0)
      while (1) mi1[-154151564];
  }
  mi2[0] = 1;
  for (int i = 1; i <= n; i++) {
    mi2[i] = (mi2[i - 1] * c) % P2;
    if (mi2[i] < 0)
      while (1) mi2[-134564522];
  }
  ni1[0] = 1;
  for (int i = 1; i <= n; i++) ni1[i] = ni1[i - 1] * nn1 % P1;
  ni2[0] = 1;
  for (int i = 1; i <= n; i++) ni2[i] = ni2[i - 1] * nn2 % P2;
}
int main() {
  pre(1000000);
  int n;
  scanf("%d", &n);
  int totlen = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", st + 1);
    int l = strlen(st + 1);
    int pos = 0;
    long long c = 62;
    long long sh1 = 0, sh2 = 0;
    for (int j = 1; j <= l && j <= totlen; j++) {
      sh1 = (sh1 * c + num(st[j])) % P1;
      sh2 = (sh2 * c + num(st[j])) % P2;
      if (sh1 < 0 || sh2 < 0)
        while (1) putchar('\n');
      if ((s1[totlen] - s1[totlen - j] * mi1[j] % P1 + P1) % P1 == sh1 &&
          (s2[totlen] - s2[totlen - j] * mi2[j] % P2 + P2) % P2 == sh2)
        pos = j;
    }
    for (int j = pos + 1; j <= l; j++) {
      Ans[++totlen] = st[j];
      s1[totlen] = (s1[totlen - 1] * c + num(Ans[totlen])) % P1;
      s2[totlen] = (s2[totlen - 1] * c + num(Ans[totlen])) % P2;
      if (s1[totlen] * c < 0 || s2[totlen] * c < 0)
        while (1) putchar('\n');
    }
  }
  for (int i = 1; i <= totlen; i++) putchar(Ans[i]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}

```