406479: GYM102419 L Cheating detection.
Description
In SPC cheating is allowed, but any way Kilani likes to check if the participants are cheating or not, (especially Omar and Wesam :P)
In SPC you can only submit codes in one programming languages which is Abu elayayeeeb programming language,a language developed by Ayoub
Ayoub didn't finish developing it yet but he created 4 commands
define $$$x$$$
$$$a = b + c$$$
read $$$x$$$
print $$$x$$$
Every command should be on one line. Kilani thinks that two students cheated if and only if you can rename the variables so that the first code becomes exactly the same as the second code.
You are given two codes, did they cheat?
InputThe first line contains one integer $$$n$$$ $$$(1 \leq n \leq 1000)$$$, which is the number of lines of the first code.
The next $$$n$$$ lines will contain one of four commands.
define $$$x$$$
$$$a$$$ = $$$b$$$ + $$$c$$$
read $$$x$$$
print $$$x$$$
Where $$$x$$$, $$$a$$$, $$$b$$$ and $$$c$$$ are a names of variables.
The first line contains one integer $$$m$$$ $$$(1 \leq m \leq 1000)$$$, which is the number of lines of the second code.
The next $$$m$$$ lines will contain one of four commands.
define $$$x$$$
$$$a$$$ = $$$b$$$ + $$$c$$$
read $$$x$$$
print $$$x$$$
where $$$x$$$, $$$a$$$, $$$b$$$ and $$$c$$$ are a names of variables.
It's guaranteed that before using any variable it will be defined, and the name of every variable will contain lowercase English letters of length at most 10, and no variable is defined twice.
The variables can't be one of the reserved word(define, print, read).
Outputif they cheated print YES otherwise print NO.
ExamplesInput5 define a define b define c a=b+c print a 5 define a define b define c a=c+b print aOutput
NOInput
5 define a define b define c a=b+c print a 5 define a define c define b a=c+b print aOutput
YESInput
5 define a define b define c a=b+c print a 5 define a define b define c a=b+c print aOutput
YES