Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 406 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 8.00

magical tales a lot.

All submissions for this problem are available.

Little Avani had been reading about magical tales a lot. Being fascinated by the power of magic tricks, she decided to learn magic. She bought a book which contained N magic tricks. Each magic trick is described as a string S consisting of characters from the set {a,b,c,d} only. Being very little, she was unable to understand any of the magic tricks. She put a lot of effort to figure out how to use those tricks. She then found that each magic trick Si is dependent on another magic trick Sj such that:

  • Sj is lexicographically smaller than Si.
  • There exits no other magic trick Sk which is lexicographically greater than Sj and lexicographically smaller than Si.
  • 1


Now she has Q queries. Each query consists of a magic trick. For each query she wants to know the magic trick it is dependent on. Help her learn the magic tricks and she will give you lots of goodies in return.

Input

The first line contains a single integer N denoting the number of magic tricks in the book.
N lines follow. Each line contains description of a magic trick.
Next line contains an integer Q denoting the number of magic tricks Avani is interested in.
Q lines follow. Each line contains a magic trick.

Output

For each query, output the magic trick which it is dependent on. If there is no such magic trick, then output -1.

Constraints

  • 1 N
  • 1 Q
  • 1 |S|
  • S contains characters from the set {a,b,c,d} only.

Example

Input:

5 aa abb bdc cda dacc 4 bdc cda aa abb


Output:

abb bdc -1 aa

Answers

(5)
Status NEW Posted 17 Sep 2017 12:09 PM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)