{"raw_statement":[{"iden":"problem statement","content":"There is a slot machine with $N$ reels.  \nThe placement of symbols on the $i$\\-th reel is represented by a string $S_i$ of length $10$ containing each of `0`, `1`, $\\ldots$, `9` exactly once.\nEach reel has a corresponding button. For each non-negative integer $t$, Takahashi can press one of the buttons of his choice (or do nothing) $t$ seconds after the reels start spinning.  \nIf the button for the $i$\\-th reel is pressed $t$ seconds after the start of the spin, the $i$\\-th reel will stop to display the $((t\\bmod{10})+1)$\\-th character of $S_i$.  \nHere, $t\\bmod{10}$ denotes the remainder when $t$ is divided by $10$.\nTakahashi wants to stop all reels to make them display the same character.  \nFind the minimum number of seconds needed to achieve his objective after the start of the spin."},{"iden":"constraints","content":"*   $2\\leq N\\leq 100$\n*   $N$ is an integer.\n*   $S_i$ is a string of length $10$ containing each of `0`, `1`, $\\ldots$, `9` exactly once."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$S_1$\n$S_2$\n$\\vdots$\n$S_N$"},{"iden":"sample input 1","content":"3\n1937458062\n8124690357\n2385760149"},{"iden":"sample output 1","content":"6\n\nTakahashi can make all reels display `8` in $6$ seconds after the start of the spin by stopping them as follows.\n\n*   $0$ seconds after the start of the spin, press the button for the $2$\\-nd reel, making it stop to display the $((0\\bmod{10})+1=1)$\\-st character of $S_2$, `8`.\n*   $2$ seconds after the start of the spin, press the button for the $3$\\-rd reel, making it stop to display the $((2\\bmod{10})+1=3)$\\-rd character of $S_3$, `8`.\n*   $6$ seconds after the start of the spin, press the button for the $1$\\-st reel, making it stop to display the $((6\\bmod{10})+1=7)$\\-th character of $S_1$, `8`.\n\nThere is no way to make all reels display the same character in five seconds or less, so the answer is $6$."},{"iden":"sample input 2","content":"5\n0123456789\n0123456789\n0123456789\n0123456789\n0123456789"},{"iden":"sample output 2","content":"40\n\nNote that he must _stop_ all reels to make them display the same character."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}