{"problem":{"name":"Karuta","description":{"content":"You are given $N$ strings consisting of lowercase English letters. Let $S_i$ be the $i$\\-th $(i = 1, 2, \\dots, N)$ of them. For two strings $x$ and $y$, $\\mathrm{LCP}(x, y)$ is defined to be the maxim","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc287_e"},"statements":[{"statement_type":"Markdown","content":"You are given $N$ strings consisting of lowercase English letters. Let $S_i$ be the $i$\\-th $(i = 1, 2, \\dots, N)$ of them.\nFor two strings $x$ and $y$, $\\mathrm{LCP}(x, y)$ is defined to be the maximum integer $n$ that satisfies all of the following conditions:\n\n*   The lengths of $x$ and $y$ are both at least $n$.\n*   For all integers $i$ between $1$ and $n$, inclusive, the $i$\\-th character of $x$ and that of $y$ are equal.\n\nFind the following value for all $i = 1, 2, \\dots, N$:\n\n*   $\\displaystyle \\max_{i \\neq j} \\mathrm{LCP}(S_i, S_j)$\n\n## Constraints\n\n*   $2 \\leq N \\leq 5 \\times 10^5$\n*   $N$ is an integer.\n*   $S_i$ is a string of length at least $1$ consisting of lowercase English letters $(i = 1, 2, \\dots, N)$.\n*   The sum of lengths of $S_i$ is at most $5 \\times 10^5$.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc287_e","tags":[],"sample_group":[["3\nabc\nabb\naac","2\n2\n1\n\n$\\mathrm{LCP}(S_1, S_2) = 2, \\mathrm{LCP}(S_1, S_3) = 1$, and $\\mathrm{LCP}(S_2, S_3) = 1$."],["11\nabracadabra\nbracadabra\nracadabra\nacadabra\ncadabra\nadabra\ndabra\nabra\nbra\nra\na","4\n3\n2\n1\n0\n1\n0\n4\n3\n2\n1"]],"created_at":"2026-03-03 11:01:14"}}