{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eThe well-known Fibonacci sequence is defined as following:\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u0026nbsp;\u0026nbsp;Here we regard n as the index of the Fibonacci number F(n).\u003cbr\u003e\u0026nbsp;\u0026nbsp;This sequence has been studied since the publication of Fibonacci\u0027s book Liber Abaci. So far, many properties of this sequence have been introduced.\u003cbr\u003e\u0026nbsp;\u0026nbsp;You had been interested in this sequence, while after reading lots of papers about it. You think there’s no need to research in it anymore because of the lack of its unrevealed properties. Yesterday, you decided to study some other sequences like Lucas sequence instead.\u003cbr\u003e\u0026nbsp;\u0026nbsp;Fibonacci came into your dream last night. “Stupid human beings. Lots of important properties of Fibonacci sequence have not been studied by anyone, for example, from the Fibonacci number 347746739…”\u003cbr\u003e\u0026nbsp;\u0026nbsp;You woke up and couldn’t remember the whole number except the first few digits Fibonacci told you. You decided to write a program to find this number out in order to continue your research on Fibonacci sequence.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;There are multiple test cases. The first line of input contains a single integer T denoting the number of test cases (T\u0026lt;\u003d50000).\u003cbr\u003e\u0026nbsp;\u0026nbsp;For each test case, there is a single line containing one non-empty string made up of at most 40 digits. And there won’t be any unnecessary leading zeroes."}},{"title":"Output","value":{"format":"HTML","content":"\u0026nbsp;\u0026nbsp;For each test case, output the smallest index of the smallest Fibonacci number whose decimal notation begins with the given digits. If no Fibonacci number with index smaller than 100000 satisfy that condition, output -1 instead – you think what Fibonacci wants to told you beyonds your ability."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e15\r\n1\r\n12\r\n123\r\n1234\r\n12345\r\n9\r\n98\r\n987\r\n9876\r\n98765\r\n89\r\n32\r\n51075176167176176176\r\n347746739\r\n5610\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 0\r\nCase #2: 25\r\nCase #3: 226\r\nCase #4: 1628\r\nCase #5: 49516\r\nCase #6: 15\r\nCase #7: 15\r\nCase #8: 15\r\nCase #9: 43764\r\nCase #10: 49750\r\nCase #11: 10\r\nCase #12: 51\r\nCase #13: -1\r\nCase #14: 1233\r\nCase #15: 22374\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}