{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"题目描述","value":{"format":"MD","content":"\n最近,对火星的一次秘密研究拉开帷幕,在这次探寻中,科学家们发现了火星上的DNA。\n\n他们发现,火星DNA包含 $n$ 个核苷酸,且由 $m$ 种不同核苷酸构成(编号为 $1$~$m$)。\n\n他们还发现出于某些特殊的原因,存在 $k$ 对核苷酸,一对这样的核苷酸不会连续出现在火星DNA中。\n\u003e 例如存在一对这样的核苷酸 (1,2) ,则核苷酸2不能紧连着核苷酸1(即DNA中不会连续出现 1,2);但是可以连续出现 2,1\n\n科学家们想知道有多少种不同的火星DNA(如果两个DNA存在一个位置,使得两个DNA的该位置的核苷酸不同,则认为这两个DNA不同)。\n"}},{"title":"输入","value":{"format":"MD","content":"第一行包含 $3$ 个整数 $n,m,k$ ,含义见题目描述;\n\n接下来 $k$ 行,每行包含一个长度为 $2$ 的字符串,字符串由小写字母和大写字母构成——字母\u0027a\u0027~\u0027z\u0027表示核苷酸 $1$~$26$,\u0027A\u0027~\u0027Z\u0027表示核苷酸 $27$~$52$;表示题目描述中的 $k$ 对核苷酸。"}},{"title":"输出","value":{"format":"MD","content":"\n一个整数,表示有多少种不同的DNA,答案对 $(10^9+7)$ 取模。"}},{"title":"数据规模","value":{"format":"MD","content":"\n$1\\leq n\\leq 10^{15},1\\leq m\\leq 52,0\\leq k\\leq m^2$。"}},{"title":"Examples","value":{"format":"MD","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3 3 2\u003cbr\u003eab\u003cbr\u003eba\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e17\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3 3 0\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e27\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e2 1 1\u003cbr\u003eaa\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e0\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eIn the second test case all possible three-nucleotide DNAs are permitted. Each nucleotide can take one of three values, thus in total there are 27 distinct three nucleotide DNAs.\u003c/p\u003e\n\u003cp\u003eIn the third test sample we cannot make any DNA of two nucleotides — the only possible nucleotide \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\" cannot occur two times consecutively.\u003c/p\u003e"}}]}