#include <stdio.h>
#define ll int
#define mn 102
char a[mn][mn][mn];
ll n, m, t, mx[mn], s[mn][mn];
#define max(a, b) (((a) > (b)) ? (a) : (b))
signed main()
{
scanf("%d", &t);
for (ll n1, i = 0; i < t; ++i)
{
scanf("%d", &n1);
++n1;
n = max(n1, n);
for (ll j = 0; j < n1; ++j)
{
scanf("%s", a[j][i]);
for (ll k = 0; a[j][i][k]; ++k)
{
s[j][i] += a[j][i][k] == ',';
}
mx[i] = max(mx[i], s[j][i]);
}
}
for (ll i = 0; i < n; ++i)
{
for (ll j = 0; j < t; ++j)
{
printf("%s", a[i][j]);
for (ll k = 0; k < mx[j] - s[i][j]; ++k)
{
printf(",");
}
printf("%c", ", "[j + 1 == t]);
}
printf("\n");
}
return 0;
}