roman Denis trip programming competition since trip long soon got bored decide come Roman invent pizza recipe Denis invent string multiplication according Denis result multiplication product string s length m t string t s_1 t s_2 ldot t s_m t s_i denote ith symbol string s denote string concatenation for example product string abc de string deadebdecde product string ab z string zazbz note unlike number multiplication product string s t necessarily equal product t sRoman jealous Denis invent cool operation decide invent stringrelated since roman beautylover decided define beauty string length long substre consist letter for example beauty string xayyaaabca equal 3 substring aaa beauty string qwerqwer equal 1 neighboring symbol differentIn order entertain Roman Denis write n string p_1 p_2 p_3 ldot p_n paper ask calculate beauty string ldot p_1 cdot p_2 cdot p_3 cdot ldot cdot p_n s cdot t denote multiplication string s t Roman have not fully realize Deniss multiplication work ask help Denis know roman impressionable guarantee beauty result string 109