Codeforces Round 454 (Div. 1, based on Technocup 2018 Elimination Round 4)


A. Shockers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
! abc
. ad
. b
! cd
? c
Output
1
Input
8
! hello
! codeforces
? c
. o
? d
? h
. l
? e
Output
2
Input
7
! ababahalamaha
? a
? b
? a
? b
? a
? h
Output
0
----------------------------------------------------------------------------------------------------
B. Seating of Students
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
Output
YES
5 4 7 2 
3 6 1 8 
Input
2 1
Output
NO
----------------------------------------------------------------------------------------------------
C. Party
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
1 2
1 3
2 3
2 5
3 4
4 5
Output
2
2 3 
Input
4 4
1 2
1 3
1 4
3 4
Output
1
1 
----------------------------------------------------------------------------------------------------
D. Power Tower
time limit per test: 4.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 1000000000
1 2 2 3 3 3
8
1 1
1 6
2 2
2 3
2 4
4 4
4 5
4 6
Output
1
1
2
4
256
3
27
597484987
----------------------------------------------------------------------------------------------------
E. Reverses
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abcxxxdef
cbaxxxfed
Output
2
7 9
1 3
----------------------------------------------------------------------------------------------------
