#K85497. Taco's Dictionary Equivalence Checker

    ID: 36654 Type: Default 1000ms 256MiB

Taco's Dictionary Equivalence Checker

Taco's Dictionary Equivalence Checker

You are given several pairs of dictionaries. Each dictionary maps words to sequences. The dictionaries are represented by a number followed by that many lines, each containing a word and its corresponding sequence. Two dictionaries are considered equivalent if they have exactly the same set of keys, and each corresponding key maps to the same sequence.

The input will contain multiple pairs of dictionaries. For each pair, you should check if the dictionaries are equivalent. The input terminates when a line with 0 is encountered.

The process to determine equivalence is as follows:

$$ D_1 \text{ is equivalent to } D_2 \iff \{ key \in D_1 \} = \{ key \in D_2 \} \text{ and } \forall key,\ d_1(key) = d_2(key). $$

inputFormat

The input is given via stdin and consists of multiple dictionary pairs. For each pair:

  • A line with an integer n indicating the number of entries in the first dictionary.
  • n lines each containing a word and its corresponding sequence separated by a space.
  • A line with an integer m indicating the number of entries in the second dictionary.
  • m lines each containing a word and its corresponding sequence separated by a space.

The input terminates with a line containing 0.

outputFormat

For each pair of dictionaries, output EQUIVALENT if the two dictionaries are equivalent; otherwise, output DIFFERENT. Each result should appear on a separate line on stdout.

## sample
2
hello h1^
world w1@
2
hello h1^
world w1@
3
fire f1*
dragon d1$
knight k2#
3
fire f1*
dragon d1$
knight k2##
1
magic m@
1
magic m@
0
EQUIVALENT

DIFFERENT EQUIVALENT

</p>