406479: GYM102419 L Cheating detection.

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. Cheating detection.time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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?

Input

The 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).

Output

if they cheated print YES otherwise print NO.

ExamplesInput
5
define a
define b
define c
a=b+c
print a
5
define a
define b
define c
a=c+b
print a
Output
NO
Input
5
define a
define b
define c
a=b+c
print a
5
define a
define c
define b
a=c+b
print a
Output
YES
Input
5
define a
define b
define c
a=b+c
print a
5
define a
define b
define c
a=b+c
print a
Output
YES

Source/Category

加入题单

上一题 下一题 算法标签: