/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⡤⠤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⠛⠉⠀⠀⠀⠀⠈⠙⢷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠶⣄⡀⠀⠀⠀⢠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠉⠛⠶⣤⣸⡇⠀⠀⠀⠀⣀⣤⣶⣶⠒⠒⠒⠶⣬⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⠴⠶⣿⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠒⠶⢿⣭⣀⡀⢻⡀⠀⠀⢠⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⠶⠛⠋⠁⠀⠀⢸⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠷⣴⣞⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠞⠉⠀⠀⠀⠀⠀⠀⢰⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠋⠀⠀⠀⠀⢀⡤⠠⡄⠀⢰⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡞⠁⠀⠀⠀⠀⣠⠖⠋⠀⣸⠇⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⢀⡀⠀⠀⠀⠀⠀⠀⢦⡀⠀⠀⠀⠸⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡼⠋⠀⠀⠀⠀⢀⣴⠋⢀⢀⡴⠋⠀⢀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣽⠀⣼⢿⡄⠀⠀⠀⠀⣆⠀⠉⢦⡀⠀⠀⠀⠘⢧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡟⠁⠀⠀⠀⠀⣠⠟⠇⠀⠈⠉⠁⠀⣀⣾⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⢰⠏⠀⠻⣄⠀⠀⠀⠹⣄⣰⠟⠁⠀⠀⠀⠀⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡟⠀⢀⣀⡖⠀⣰⠏⠀⠀⠀⠀⠀⢀⣼⣿⠋⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣧⡟⠀⠀⠀⠹⣦⠀⠀⠀⠀⠁⠀⣶⠀⠀⣴⠛⢧⠀⢻⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣠⠞⣩⡟⠀⠀⠈⠉⠀⢀⡟⠀⠀⢀⣀⣠⣤⣾⡿⠗⠒⠚⣿⠠⣤⠀⠀⠀⠀⠀⠀⠀⢸⣿⠓⠒⠲⠶⠶⠾⢷⣤⣀⣀⠀⠀⠙⣧⠀⠹⣆⣼⠃⠀⢷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⢀⡴⠟⢁⡼⣿⠁⠀⠀⠀⠀⠀⢸⠃⠀⠀⠈⠉⢠⡾⠋⠀⠀⠀⠀⠸⣆⠙⣧⡀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠻⣆⠉⠁⠀⠀⢹⡄⠀⠈⠁⠀⠀⠘⣷⢦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣠⡶⠋⢀⡴⠋⢰⡏⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⣠⠟⠀⠀⠀⠀⠀⠀⠀⢻⡄⢸⣷⣄⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠈⢳⣄⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢰⣾⡥⠴⠞⠋⠀⠀⣼⠀⠀⠀⠀⠀⠀⠀⣸⠀⠀⠀⣰⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⣷⠙⠷⣄⡀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢷⣄⠀⣿⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠀⠀⠀⠀⠀⢸⡄⠀⣼⢏⣀⣤⣶⣦⣤⣶⣶⣶⣶⣶⣿⣿⣾⡆⠀⠈⠻⢦⣼⡇⢰⣶⣶⣶⣶⣶⣶⣶⣤⣤⣤⣦⠙⢧⣿⠀⠀⠀⠀⠀⠀⢸⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠘⣇⣼⠏⠘⣿⡿⢿⣿⣿⣿⣿⣿⡏⠉⠉⠉⠙⠃⠀⠀⠀⠀⠉⠁⠘⠛⢻⣿⣿⣿⣿⣿⣟⠛⢛⠷⠀⠀⣿⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⡟⣷⠀⠀⠀⠀⠀⠀⠀⢻⡏⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣷⢹⣆⠀⠀⠀⠀⠀⠀⠈⣷⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢿⠘⣿⣆⠀⠀⠀⠀⠀⠐⠘⣧⠀⠀⠀⠘⢿⣿⣿⣿⣿⠏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⡿⠃⠀⠀⠀⣼⠃⠀⠀⠀⠀⠀⣰⠟⠐⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⣇⣿⠙⣧⣄⠀⠀⠀⠀⠀⠘⢧⡀⠀⠀⠈⢹⠿⢟⡋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢻⡿⠀⡀⠀⠀⣼⠃⠀⠀⠀⠀⣀⡾⠋⠀⣴⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⠀⣿⠝⠳⣤⣀⡀⠀⠀⠈⢷⣤⠇⢠⡞⠠⠾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠟⠁⡾⠃⣠⡾⠃⠀⠀⣀⣤⠾⠋⠀⠀⠀⡿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣸⣿⠀⠀⠀⠉⠙⠓⡶⠦⠤⣿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠓⢰⡿⠤⠴⠶⣿⠉⠀⠀⠀⠀⠀⢠⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⢻⠀⠀⠀⠀⠀⠃⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢲⣄⠀⠀⠀⠀⠀⠀⠀⢀⣴⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡟⠀⠀⠀⠀⠀⠀⢸⡇⣸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡿⢸⡇⠀⠀⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠲⠤⣤⠤⠴⠞⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡏⠀⠀⠀⠀⠀⠀⢸⠇⠈⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⢸⡇⠀⠀⠀⠀⠀⢸⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⡇⠀⠀⠀⠀⠀⠀⢺⢀⠀⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⢷⠛⣇⠀⠀⠀⠀⠀⠈⣿⠉⠻⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣅⣸⠀⠀⠀⠀⠀⠀⢀⣿⢸⡀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠘⣀⣿⠀⠀⠀⠀⠀⢷⢸⡄⠀⠈⠙⠶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡴⠟⠁⠀⠈⣿⠀⠀⠀⠀⠀⠀⠈⡟⣼⡇⠀⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢿⢿⠀⠀⠀⠀⠀⠀⠈⣧⠀⠀⠀⠀⠀⠉⠛⠶⢤⣤⣀⣀⠀⣀⡀⠀⠀⠀⠀⠀⢀⣠⡴⠞⠋⠁⠀⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⢠⡇⢹⣤⠀⢹⡄⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠀⠀⡿⢸⡆⠀⠀⠀⠀⠀⠀⢻⡆⠀⠀⠀⠀⠀⠀⠀⠀⣿⡿⠟⠋⠉⠁⠀⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠀⠀⠀⠀⢸⠇⠀⠀⠀⠀⠀⠀⢸⡇⠈⣟⠀⠈⣷⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢰⡟⠀⢰⡇⠘⡇⠀⠀⠀⠀⠀⠘⠀⣷⠀⠀⠀⠀⠀⠀⠀⠀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠆⠀⠀⠀⠀⠀⠀⣼⠁⠀⢻⡀⠀⠸⣇⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⣼⠁⠀⣿⠀⠀⠀⠀⠀⠀⠀⠻⣇⣀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠀⠀⣰⡇⠀⠀⠀⠀⠀⠀⠀⣿⡆⠀⠈⣷⡀⠀⢻⡄⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢰⡇⠀⢀⡏⠀⠀⢻⠀⠀⠀⠀⠀⠀⠀⠀⢻⣦⣄⠀⠀⠀⠀⣠⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⣠⣾⣿⠀⠀⠀⠀⠀⠀⢠⣠⡇⡇⠀⠀⠸⣯⡀⠀⢷⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⡾⠀⠀⣼⠁⠀⠀⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢿⣽⡧⠴⢶⣿⣿⠖⠒⠛⠛⠃⠀⠀⠀⠚⠋⠉⠉⠉⠙⠓⠲⢾⡛⠻⣽⠃⠀⠀⠀⠀⠀⠀⢸⣿⣃⠀⠀⠀⠀⢹⣷⠀⠘⣧⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣸⠃⠀⢸⡏⠀⠀⠀⢀⣿⠀⠀⠀⠀⢀⣀⠀⠈⠈⢷⠖⠚⠋⠁⢹⡇⠀⢀⣴⠶⠶⢦⣄⣀⣤⡶⠶⠤⠤⠤⠶⠾⠇⢰⡏⠀⠀⠀⠀⠀⠀⠻⣿⣿⣤⡀⠀⠀⠀⠀⢿⣀⠀⠸⣆⠀⠀⠀
⠀⠀⠀⠀⠀⢰⠏⠀⢀⡿⠀⠀⠀⣰⠟⢹⣿⡄⠀⠀⠀⠻⣄⠀⠀⠘⣷⣤⣄⣀⣈⡙⠛⢹⡷⢶⣦⣴⣾⣛⣻⢯⣴⣦⠴⠖⠃⠀⢀⡾⠀⠀⠀⠀⠀⠀⠀⢰⣿⡇⠀⠹⣆⠀⠀⠸⡞⣧⣆⠀⠹⣄⠀⠀
⠀⠀⠀⠀⢠⡟⠀⠀⡼⠁⠀⠀⣰⠏⠀⠈⣟⣧⠀⠀⠀⠀⢻⣆⠀⠀⠈⣧⡿⠀⠈⠉⠛⠛⣻⣿⡿⢿⣿⡍⠉⠀⠀⠀⠀⠀⠀⠀⡾⠁⠀⠀⠀⢀⣴⠀⠀⡾⣿⠁⠀⠀⠘⣧⠀⠀⢿⠘⣟⠀⠀⢻⡄⠀
⠀⠀⢀⣠⡟⠀⢀⡾⠃⠀⠀⣰⡏⠀⠀⠀⣻⠘⣧⠀⠀⠀⠀⢻⣷⡄⠀⠘⢷⡀⠀⠀⠀⠀⠩⣉⠁⠈⣛⡁⠀⠀⠀⠀⠀⠀⣀⣾⠁⠀⠀⣀⣠⣟⠁⠀⣠⣤⡟⠀⠀⠀⠀⠘⣧⡄⠘⡇⠙⣇⠀⠀⠻
*/
#include <bits/stdc++.h>
using namespace std;
#define i64 long long
#define ld long double
#define bit(n,i) ((n>>i)&1)
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define FOD(i,a,b) for(int i=a; i>=b; i--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define __sumairu__ main()
#define die_hard_onimai_fan void seggs()
#define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
#define brute(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".ans","w",stdout);}
#define TIME (1.0*clock()/CLOCKS_PER_SEC)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ai(n) array<int,n>
#define dbg(x) {cerr<<#x<<' '<<x<<endl;}
#define dbgArr(arr,n) {cerr<<#arr;FOR(_i,1,n)cerr<<' '<<(arr)[_i];cerr<<endl;}
template <typename T,typename U>
ostream& operator<<(ostream &os,pair<T,U>p){
return os<<"{"<<p.fi<<", "<<p.se<<"}";
}
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
i64 Rand(i64 l,i64 r)
{
i64 ans=l+1ll*rd()*rd()%(r-l+1);
assert(l<=ans&&ans<=r);
return ans;
}
#define i64 long long
#define debug 0
//const int mod=1e9+7;
//const int mod=998244353;
const int inf=2e9;
///check the limits, dummy
const int N=2e5+5;
const i64 base=1e9+7;
const i64 mod=(1ll<<53)+5;
string a,b,c;
int n;
set<i64>H;
int q;
string s;
i64 p[N];
string comb(string a,string b)
{
string ans;
FOR(i,0,n-1)
{
if(a[i]!=b[i])ans.pb(a[i]^b[i]^'J'^'O'^'I');
else ans.pb(a[i]);
}
return ans;
}
i64 getHash(string s)
{
i64 H=0;
for(char c:s)H=((__int128)H*base%mod+c)%mod;
return H;
}
i64 val[N];
struct seg
{
struct node
{
i64 H;
int len;
friend node operator+(const node&u,const node&v)
{
node ans;
ans.len=u.len+v.len;
ans.H=((__int128)u.H*p[v.len]+v.H)%mod;
return ans;
}
}t[N*4];
int lz[N*4];
void build(int id,int l,int r)
{
if(l==r)
{
t[id].H=s[l];
t[id].len=1;
return;
}
int m=(l+r)/2;
build(id*2,l,m);
build(id*2+1,m+1,r);
t[id]=t[id*2]+t[id*2+1];
}
void push(int id,int l,int r)
{
if(!lz[id])return;
int v=lz[id];
int m=(l+r)/2;
t[id*2].H=((__int128)val[m-l+1-1]*v)%mod;
t[id*2+1].H=((__int128)val[r-m-1]*v)%mod;
FOR(i,id*2,id*2+1)lz[i]=v;
lz[id]=0;
}
void up(int id,int l,int r,int x,int y,int v)
{
if(x>r||y<l)return;
if(x<=l&&r<=y)
{
t[id].H=((__int128)val[r-l+1-1]*v)%mod;
lz[id]=v;
return;
}
int m=(l+r)/2;
push(id,l,r);
up(id*2,l,m,x,y,v);
up(id*2+1,m+1,r,x,y,v);
t[id]=t[id*2]+t[id*2+1];
}
i64 get(int id,int l,int r,int p)
{
if(p>r||p<l)return 0;
if(l==r)return t[id].H;
int m=(l+r)/2;
push(id,l,r);
return get(id*2,l,m,p)+get(id*2+1,m+1,r,p);
}
}T;
die_hard_onimai_fan
{
cin>>n>>a>>b>>c;
H.insert(getHash(a));
H.insert(getHash(b));
H.insert(getHash(c));
H.insert(getHash(comb(a,b)));
H.insert(getHash(comb(b,c)));
H.insert(getHash(comb(c,a)));
H.insert(getHash(comb(comb(a,b),c)));
H.insert(getHash(comb(comb(b,c),a)));
H.insert(getHash(comb(comb(c,a),b)));
p[0]=val[0]=1;
FOR(i,1,n)
{
p[i]=(__int128)p[i-1]*base%mod;
val[i]=(1ll*val[i-1]+p[i])%mod;
}
cin>>q>>s;
s=' '+s;
T.build(1,1,n);
if(H.count(T.t[1].H))cout<<"Yes\n";
else cout<<"No\n";
while(q--)
{
int l,r;
cin>>l>>r;
char c;
cin>>c;
T.up(1,1,n,l,r,c);
if(H.count(T.t[1].H))cout<<"Yes\n";
else cout<<"No\n";
}
}
__sumairu__
{
FAST
file("");
int tt=1;//cin>>tt;
while(tt--)seggs();
cerr<<"\nTime elapsed: "<<TIME<<" s.\n";
}
/**
4
JOJO
JJOI
OJOO
3
JJJJ
1 4 O
2 2 J
2 4 I
*/
Compilation message
Main.cpp:57:21: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | #define __sumairu__ main()
| ^~~~
Main.cpp:224:1: note: in expansion of macro '__sumairu__'
224 | __sumairu__
| ^~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:59:53: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | #define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:227:5: note: in expansion of macro 'file'
227 | file("");
| ^~~~
Main.cpp:59:83: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | #define file(name) if(fopen(name".inp","r")){freopen(name".inp","r",stdin);freopen(name".out","w",stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:227:5: note: in expansion of macro 'file'
227 | file("");
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2352 KB |
Output is correct |
2 |
Correct |
56 ms |
2388 KB |
Output is correct |
3 |
Correct |
57 ms |
2316 KB |
Output is correct |
4 |
Correct |
48 ms |
2440 KB |
Output is correct |
5 |
Correct |
61 ms |
2372 KB |
Output is correct |
6 |
Correct |
47 ms |
2384 KB |
Output is correct |
7 |
Correct |
46 ms |
2388 KB |
Output is correct |
8 |
Correct |
48 ms |
2384 KB |
Output is correct |
9 |
Correct |
63 ms |
2388 KB |
Output is correct |
10 |
Correct |
49 ms |
2384 KB |
Output is correct |
11 |
Correct |
51 ms |
2384 KB |
Output is correct |
12 |
Correct |
55 ms |
2388 KB |
Output is correct |
13 |
Correct |
62 ms |
2400 KB |
Output is correct |
14 |
Correct |
57 ms |
2384 KB |
Output is correct |
15 |
Correct |
65 ms |
2384 KB |
Output is correct |
16 |
Correct |
49 ms |
2388 KB |
Output is correct |
17 |
Correct |
66 ms |
2588 KB |
Output is correct |
18 |
Correct |
53 ms |
2480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2352 KB |
Output is correct |
2 |
Correct |
56 ms |
2388 KB |
Output is correct |
3 |
Correct |
57 ms |
2316 KB |
Output is correct |
4 |
Correct |
48 ms |
2440 KB |
Output is correct |
5 |
Correct |
61 ms |
2372 KB |
Output is correct |
6 |
Correct |
47 ms |
2384 KB |
Output is correct |
7 |
Correct |
46 ms |
2388 KB |
Output is correct |
8 |
Correct |
48 ms |
2384 KB |
Output is correct |
9 |
Correct |
63 ms |
2388 KB |
Output is correct |
10 |
Correct |
49 ms |
2384 KB |
Output is correct |
11 |
Correct |
51 ms |
2384 KB |
Output is correct |
12 |
Correct |
55 ms |
2388 KB |
Output is correct |
13 |
Correct |
62 ms |
2400 KB |
Output is correct |
14 |
Correct |
57 ms |
2384 KB |
Output is correct |
15 |
Correct |
65 ms |
2384 KB |
Output is correct |
16 |
Correct |
49 ms |
2388 KB |
Output is correct |
17 |
Correct |
66 ms |
2588 KB |
Output is correct |
18 |
Correct |
53 ms |
2480 KB |
Output is correct |
19 |
Correct |
209 ms |
19460 KB |
Output is correct |
20 |
Correct |
214 ms |
17664 KB |
Output is correct |
21 |
Correct |
135 ms |
18772 KB |
Output is correct |
22 |
Correct |
162 ms |
18156 KB |
Output is correct |
23 |
Correct |
85 ms |
4268 KB |
Output is correct |
24 |
Correct |
133 ms |
4176 KB |
Output is correct |
25 |
Correct |
159 ms |
19460 KB |
Output is correct |
26 |
Correct |
158 ms |
19340 KB |
Output is correct |
27 |
Correct |
181 ms |
19416 KB |
Output is correct |
28 |
Correct |
195 ms |
19204 KB |
Output is correct |
29 |
Correct |
158 ms |
19012 KB |
Output is correct |
30 |
Correct |
110 ms |
4176 KB |
Output is correct |
31 |
Correct |
168 ms |
19236 KB |
Output is correct |
32 |
Correct |
171 ms |
18648 KB |
Output is correct |
33 |
Correct |
106 ms |
4120 KB |
Output is correct |
34 |
Correct |
169 ms |
19348 KB |
Output is correct |
35 |
Correct |
126 ms |
17720 KB |
Output is correct |
36 |
Correct |
84 ms |
4188 KB |
Output is correct |
37 |
Correct |
84 ms |
4156 KB |
Output is correct |
38 |
Correct |
189 ms |
17460 KB |
Output is correct |
39 |
Correct |
117 ms |
17372 KB |
Output is correct |
40 |
Correct |
124 ms |
12336 KB |
Output is correct |
41 |
Correct |
241 ms |
19460 KB |
Output is correct |
42 |
Correct |
70 ms |
16644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2352 KB |
Output is correct |
2 |
Correct |
56 ms |
2388 KB |
Output is correct |
3 |
Correct |
57 ms |
2316 KB |
Output is correct |
4 |
Correct |
48 ms |
2440 KB |
Output is correct |
5 |
Correct |
61 ms |
2372 KB |
Output is correct |
6 |
Correct |
47 ms |
2384 KB |
Output is correct |
7 |
Correct |
46 ms |
2388 KB |
Output is correct |
8 |
Correct |
48 ms |
2384 KB |
Output is correct |
9 |
Correct |
63 ms |
2388 KB |
Output is correct |
10 |
Correct |
49 ms |
2384 KB |
Output is correct |
11 |
Correct |
51 ms |
2384 KB |
Output is correct |
12 |
Correct |
55 ms |
2388 KB |
Output is correct |
13 |
Correct |
62 ms |
2400 KB |
Output is correct |
14 |
Correct |
57 ms |
2384 KB |
Output is correct |
15 |
Correct |
65 ms |
2384 KB |
Output is correct |
16 |
Correct |
49 ms |
2388 KB |
Output is correct |
17 |
Correct |
66 ms |
2588 KB |
Output is correct |
18 |
Correct |
53 ms |
2480 KB |
Output is correct |
19 |
Correct |
58 ms |
2384 KB |
Output is correct |
20 |
Correct |
68 ms |
2384 KB |
Output is correct |
21 |
Correct |
51 ms |
2392 KB |
Output is correct |
22 |
Correct |
50 ms |
2384 KB |
Output is correct |
23 |
Correct |
50 ms |
2384 KB |
Output is correct |
24 |
Correct |
62 ms |
2388 KB |
Output is correct |
25 |
Correct |
49 ms |
2544 KB |
Output is correct |
26 |
Correct |
47 ms |
2388 KB |
Output is correct |
27 |
Correct |
52 ms |
2488 KB |
Output is correct |
28 |
Correct |
44 ms |
2256 KB |
Output is correct |
29 |
Correct |
50 ms |
2388 KB |
Output is correct |
30 |
Correct |
44 ms |
2384 KB |
Output is correct |
31 |
Correct |
52 ms |
2592 KB |
Output is correct |
32 |
Correct |
69 ms |
2388 KB |
Output is correct |
33 |
Correct |
58 ms |
2384 KB |
Output is correct |
34 |
Correct |
46 ms |
2388 KB |
Output is correct |
35 |
Correct |
52 ms |
2384 KB |
Output is correct |
36 |
Correct |
53 ms |
2384 KB |
Output is correct |
37 |
Correct |
51 ms |
2388 KB |
Output is correct |
38 |
Correct |
51 ms |
2384 KB |
Output is correct |
39 |
Correct |
54 ms |
2584 KB |
Output is correct |
40 |
Correct |
52 ms |
2396 KB |
Output is correct |
41 |
Correct |
52 ms |
2384 KB |
Output is correct |
42 |
Correct |
54 ms |
2388 KB |
Output is correct |
43 |
Correct |
51 ms |
2388 KB |
Output is correct |
44 |
Correct |
66 ms |
2372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
2352 KB |
Output is correct |
2 |
Correct |
56 ms |
2388 KB |
Output is correct |
3 |
Correct |
57 ms |
2316 KB |
Output is correct |
4 |
Correct |
48 ms |
2440 KB |
Output is correct |
5 |
Correct |
61 ms |
2372 KB |
Output is correct |
6 |
Correct |
47 ms |
2384 KB |
Output is correct |
7 |
Correct |
46 ms |
2388 KB |
Output is correct |
8 |
Correct |
48 ms |
2384 KB |
Output is correct |
9 |
Correct |
63 ms |
2388 KB |
Output is correct |
10 |
Correct |
49 ms |
2384 KB |
Output is correct |
11 |
Correct |
51 ms |
2384 KB |
Output is correct |
12 |
Correct |
55 ms |
2388 KB |
Output is correct |
13 |
Correct |
62 ms |
2400 KB |
Output is correct |
14 |
Correct |
57 ms |
2384 KB |
Output is correct |
15 |
Correct |
65 ms |
2384 KB |
Output is correct |
16 |
Correct |
49 ms |
2388 KB |
Output is correct |
17 |
Correct |
66 ms |
2588 KB |
Output is correct |
18 |
Correct |
53 ms |
2480 KB |
Output is correct |
19 |
Correct |
209 ms |
19460 KB |
Output is correct |
20 |
Correct |
214 ms |
17664 KB |
Output is correct |
21 |
Correct |
135 ms |
18772 KB |
Output is correct |
22 |
Correct |
162 ms |
18156 KB |
Output is correct |
23 |
Correct |
85 ms |
4268 KB |
Output is correct |
24 |
Correct |
133 ms |
4176 KB |
Output is correct |
25 |
Correct |
159 ms |
19460 KB |
Output is correct |
26 |
Correct |
158 ms |
19340 KB |
Output is correct |
27 |
Correct |
181 ms |
19416 KB |
Output is correct |
28 |
Correct |
195 ms |
19204 KB |
Output is correct |
29 |
Correct |
158 ms |
19012 KB |
Output is correct |
30 |
Correct |
110 ms |
4176 KB |
Output is correct |
31 |
Correct |
168 ms |
19236 KB |
Output is correct |
32 |
Correct |
171 ms |
18648 KB |
Output is correct |
33 |
Correct |
106 ms |
4120 KB |
Output is correct |
34 |
Correct |
169 ms |
19348 KB |
Output is correct |
35 |
Correct |
126 ms |
17720 KB |
Output is correct |
36 |
Correct |
84 ms |
4188 KB |
Output is correct |
37 |
Correct |
84 ms |
4156 KB |
Output is correct |
38 |
Correct |
189 ms |
17460 KB |
Output is correct |
39 |
Correct |
117 ms |
17372 KB |
Output is correct |
40 |
Correct |
124 ms |
12336 KB |
Output is correct |
41 |
Correct |
241 ms |
19460 KB |
Output is correct |
42 |
Correct |
70 ms |
16644 KB |
Output is correct |
43 |
Correct |
58 ms |
2384 KB |
Output is correct |
44 |
Correct |
68 ms |
2384 KB |
Output is correct |
45 |
Correct |
51 ms |
2392 KB |
Output is correct |
46 |
Correct |
50 ms |
2384 KB |
Output is correct |
47 |
Correct |
50 ms |
2384 KB |
Output is correct |
48 |
Correct |
62 ms |
2388 KB |
Output is correct |
49 |
Correct |
49 ms |
2544 KB |
Output is correct |
50 |
Correct |
47 ms |
2388 KB |
Output is correct |
51 |
Correct |
52 ms |
2488 KB |
Output is correct |
52 |
Correct |
44 ms |
2256 KB |
Output is correct |
53 |
Correct |
50 ms |
2388 KB |
Output is correct |
54 |
Correct |
44 ms |
2384 KB |
Output is correct |
55 |
Correct |
52 ms |
2592 KB |
Output is correct |
56 |
Correct |
69 ms |
2388 KB |
Output is correct |
57 |
Correct |
58 ms |
2384 KB |
Output is correct |
58 |
Correct |
46 ms |
2388 KB |
Output is correct |
59 |
Correct |
52 ms |
2384 KB |
Output is correct |
60 |
Correct |
53 ms |
2384 KB |
Output is correct |
61 |
Correct |
51 ms |
2388 KB |
Output is correct |
62 |
Correct |
51 ms |
2384 KB |
Output is correct |
63 |
Correct |
54 ms |
2584 KB |
Output is correct |
64 |
Correct |
52 ms |
2396 KB |
Output is correct |
65 |
Correct |
52 ms |
2384 KB |
Output is correct |
66 |
Correct |
54 ms |
2388 KB |
Output is correct |
67 |
Correct |
51 ms |
2388 KB |
Output is correct |
68 |
Correct |
66 ms |
2372 KB |
Output is correct |
69 |
Correct |
194 ms |
18128 KB |
Output is correct |
70 |
Correct |
225 ms |
17704 KB |
Output is correct |
71 |
Correct |
91 ms |
4200 KB |
Output is correct |
72 |
Correct |
88 ms |
4284 KB |
Output is correct |
73 |
Correct |
85 ms |
4180 KB |
Output is correct |
74 |
Correct |
145 ms |
18280 KB |
Output is correct |
75 |
Correct |
85 ms |
4268 KB |
Output is correct |
76 |
Correct |
172 ms |
19376 KB |
Output is correct |
77 |
Correct |
154 ms |
18388 KB |
Output is correct |
78 |
Correct |
101 ms |
4172 KB |
Output is correct |
79 |
Correct |
86 ms |
4180 KB |
Output is correct |
80 |
Correct |
133 ms |
17636 KB |
Output is correct |
81 |
Correct |
86 ms |
4220 KB |
Output is correct |
82 |
Correct |
156 ms |
19304 KB |
Output is correct |
83 |
Correct |
191 ms |
18856 KB |
Output is correct |
84 |
Correct |
88 ms |
4176 KB |
Output is correct |
85 |
Correct |
86 ms |
4176 KB |
Output is correct |
86 |
Correct |
157 ms |
17820 KB |
Output is correct |
87 |
Correct |
171 ms |
19436 KB |
Output is correct |
88 |
Correct |
94 ms |
4296 KB |
Output is correct |
89 |
Correct |
162 ms |
18632 KB |
Output is correct |
90 |
Correct |
166 ms |
19284 KB |
Output is correct |
91 |
Correct |
100 ms |
4296 KB |
Output is correct |
92 |
Correct |
164 ms |
17720 KB |
Output is correct |
93 |
Correct |
87 ms |
4180 KB |
Output is correct |
94 |
Correct |
87 ms |
4232 KB |
Output is correct |
95 |
Correct |
90 ms |
4180 KB |
Output is correct |
96 |
Correct |
191 ms |
17564 KB |
Output is correct |
97 |
Correct |
125 ms |
17408 KB |
Output is correct |
98 |
Correct |
140 ms |
12484 KB |
Output is correct |
99 |
Correct |
243 ms |
19696 KB |
Output is correct |
100 |
Correct |
66 ms |
16892 KB |
Output is correct |