1
//
3366 Accepted 464K 0MS G++ 1180B PKU
2
3 #include < iostream >
4 #include < map >
5 #include < string >
6
7 using namespace std ;
8
9 const int size = 110 ;
10
11 map < string , string > mp ;
12
13 string stra, strb ;
14
15 int ink, inn ;
16
17 int main()
18 {
19 while ( scanf( " %d %d " , & ink, & inn ) != EOF )
20 {
21 mp.clear() ;
22
23 for ( int i = 1 ; i <= ink; i ++ )
24 {
25 // scanf( "%s", stra ) ; scanf( "%s", strb ) ;
26 cin >> stra >> strb ;
27 mp.insert( make_pair(stra, strb) ) ;
28 }
29
30 for ( int i = 1 ; i <= inn; i ++ )
31 {
32 // scanf( "%s", stra ) ;
33 cin >> stra ;
34 if ( mp.count(stra) ) cout << mp[stra] << endl ;
35 else
36 {
37 int len = stra.size() ;
38 if ( ' y ' == stra[len - 1 ] )
39 {
40 if ( ( ' a ' == stra[len - 2 ] || ' e ' == stra[len - 2 ] || ' i ' == stra[len - 2 ] || ' o ' == stra[len - 2 ] || ' u ' == stra[len - 2 ]) )
41 {
42 stra += ' s ' ; cout << stra << endl ;
43 }
44 else
45 {
46 stra[len - 1 ] = ' i ' ; stra += " es " ; cout << stra << endl ;
47 }
48 }
49 else if ( ' o ' == stra[len - 1 ] || ' s ' == stra[len - 1 ] || ' x ' == stra[len - 1 ] || ' h ' == stra[len - 1 ] && ( ' s ' == stra[len - 2 ] || ' c ' == stra[len - 2 ]) )
50 {
51 stra += " es " ; cout << stra << endl ;
52 }
53 else
54 {
55 stra += ' s ' ; cout << stra << endl ;
56 }
57 }
58 }
59 }
60
61 return 0 ;
62 }
2
3 #include < iostream >
4 #include < map >
5 #include < string >
6
7 using namespace std ;
8
9 const int size = 110 ;
10
11 map < string , string > mp ;
12
13 string stra, strb ;
14
15 int ink, inn ;
16
17 int main()
18 {
19 while ( scanf( " %d %d " , & ink, & inn ) != EOF )
20 {
21 mp.clear() ;
22
23 for ( int i = 1 ; i <= ink; i ++ )
24 {
25 // scanf( "%s", stra ) ; scanf( "%s", strb ) ;
26 cin >> stra >> strb ;
27 mp.insert( make_pair(stra, strb) ) ;
28 }
29
30 for ( int i = 1 ; i <= inn; i ++ )
31 {
32 // scanf( "%s", stra ) ;
33 cin >> stra ;
34 if ( mp.count(stra) ) cout << mp[stra] << endl ;
35 else
36 {
37 int len = stra.size() ;
38 if ( ' y ' == stra[len - 1 ] )
39 {
40 if ( ( ' a ' == stra[len - 2 ] || ' e ' == stra[len - 2 ] || ' i ' == stra[len - 2 ] || ' o ' == stra[len - 2 ] || ' u ' == stra[len - 2 ]) )
41 {
42 stra += ' s ' ; cout << stra << endl ;
43 }
44 else
45 {
46 stra[len - 1 ] = ' i ' ; stra += " es " ; cout << stra << endl ;
47 }
48 }
49 else if ( ' o ' == stra[len - 1 ] || ' s ' == stra[len - 1 ] || ' x ' == stra[len - 1 ] || ' h ' == stra[len - 1 ] && ( ' s ' == stra[len - 2 ] || ' c ' == stra[len - 2 ]) )
50 {
51 stra += " es " ; cout << stra << endl ;
52 }
53 else
54 {
55 stra += ' s ' ; cout << stra << endl ;
56 }
57 }
58 }
59 }
60
61 return 0 ;
62 }