VK Cup 2018 - Квалификация 1


A. Login Verification
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1_wat
2
2_wat
wat_1
Output
Yes
Input
000
3
00
ooA
oOo
Output
No
Input
_i_
3
__i_
_1_
I
Output
No
Input
La0
3
2a0
La1
1a0
Output
No
Input
abc
1
aBc
Output
No
Input
0Lil
2
LIL0
0Ril
Output
Yes
----------------------------------------------------------------------------------------------------
B. Chat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 0
0 1 1 2 3 2
Output
1 2 2 3 3 3 
Input
10 1
0 1 0 3 4 5 2 3 7 0
Output
2 3 3 4 5 6 6 6 8 2 
Input
2 2
0 1
Output
2 2 
----------------------------------------------------------------------------------------------------
C. Dependency management
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a 3
2
b 1
c 1
 
b 2
0
 
b 1
1
b 2
 
c 1
1
b 2
Output
2
b 1
c 1
Input
9
codehorses 5
3
webfrmk 6
mashadb 1
mashadb 2
 
commons 2
0
 
mashadb 3
0
 
webfrmk 6
2
mashadb 3
commons 2
 
extra 4
1
extra 3
 
extra 3
0
 
extra 1
0
 
mashadb 1
1
extra 3
 
mashadb 2
1
extra 1
Output
4
commons 2
extra 1
mashadb 2
webfrmk 6
Input
3
abc 1
2
abc 3
cba 2
abc 3
0
cba 2
0
Output
1
cba 2
----------------------------------------------------------------------------------------------------
D. Autocompletion
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
snow affects sports such as skiing, snowboarding, and snowmachine travel.
snowboarding is a recreational activity and olympic and paralympic sport.
Output
141
Input
'co-co-co, codeforces?!'
Output
25
Input
thun-thun-thunder, thunder, thunder
thunder, thun-, thunder
thun-thun-thunder, thunder
thunder, feel the thunder
lightning then the thunder
thunder, feel the thunder
lightning then the thunder
thunder, thunder
Output
183
----------------------------------------------------------------------------------------------------
