E. Monasisa - Gold
time limit per test
2 s
memory limit per test
256 megabytes
input
standard input
output
standard output
"قال الشاعر الشهير أحمد سيد أحمد ربيع في منشورة له على صفحة الإنستغرام: "لوحة الموناسيسا تبصلها من أي حتة تلاقيها بتاخد منك فلوس

Reef and Abdel Fattah El-Sisi are playing a game. They are given a grid $$$a$$$ of size $$$n$$$ x $$$m$$$. In this game, Reef can only win if every pair of adjacent cells has the same product, otherwise El-Sisi wins. A cell is said to be adjacent to another cell if they share a side. You have to process $$$q$$$ queries on this grid of the following format:

  • $$$i$$$ $$$j$$$ $$$x$$$ — set $$$a_{ij}$$$ $$$=$$$ $$$x$$$

We're interested in knowing if Reef can win after each query, output $$$\small\textbf{REEF}$$$ if Reef can win after the query and $$$\small\textbf{EL-SISI}$$$ otherwise.

Don't worry, in this game El-Sisi can actually lose sometimes!

And yes, Aboud and Fakher are still playing 2v2v2v2.

Input

The first line contains an integer $$$n$$$ $$$(1≤n≤500, 1≤m≤500, 1≤q≤10^5)$$$ — the number of rows, columns and queries respectively

The following $$$n$$$ lines contain $$$m$$$ integers each, the $$$j$$$-th element in the $$$i$$$-th line is $$$a_{ij}$$$ $$$(0≤a_{ij}≤10^9)$$$

Then follows $$$q$$$ queries $$$i$$$ $$$j$$$ $$$x$$$ $$$(1≤i≤n, 1≤j≤m, 0≤x≤10^9)$$$

Output

After each query output $$$\small\textbf{REEF}$$$ if Reef can win and $$$\small\textbf{EL-SISI}$$$ otherwise

Examples
Input
1 1 1
1
1 1 0
Output
REEF
Input
2 2 2
1 2
3 4
1 2 3
2 2 1
Output
EL-SISI
REEF
Input
2 4 5
0 0 0 0
1 2 3 4
2 1 0
2 3 0
1 1 4
1 2 5
1 1 0
Output
EL-SISI
REEF
REEF
EL-SISI
EL-SISI