This page is still under construction.

Parts of this page are still being built. What you see may change.

Keyboard Queries

Time limit1sMemory limit1024 MB

Summary
Given palindrome facts about substrings of S, decide whether two substrings must be equal, cannot be equal, or remain undetermined.
Level

Hard8 of 10

Topics
Union-find, String matching, String
Solved
No attempts yet

Problem

Katrín and her friends are university students who attend a seminar every week. At the start of each seminar, the professor splits the students into groups at random. Katrín and her friends dislike random groups. They want to form a group together so they can chat and avoid getting to know the other students.

The professor keeps a secret string SS of length nn on their computer. This string seeds the random group generation. To generate groups, a program named manager runs on a substring of SS. Sometimes the professor mistypes and writes manacher instead, which means the substring is a palindrome. Can Katrín use this information to predict the group division?

The string SS has nn characters over an unknown alphabet. You are given qq queries of two types.

  • 1 l r: The substring of SS from index ll through index rr is a palindrome.
  • 2 a b x y: Determine whether the substring from index aa through bb equals the substring from index xx through yy, given the information from the previous queries.

Input

The first line contains two integers nn and qq (1≤n≤1051 \leq n \leq 10^5, 1≤q≤2⋅1051 \leq q \leq 2 \cdot 10^5), the length of the string and the number of queries. Each of the following qq lines starts with 1 or 2, the query type.

For type 1, two integers ll and rr follow (1≤l≤r≤n1 \leq l \leq r \leq n). For type 2, four integers aa, bb, xx, yy follow (1≤a≤b≤n1 \leq a \leq b \leq n, 1≤x≤y≤n1 \leq x \leq y \leq n).

Output

For each query of the second type, print "Equal" if the two substrings must be equal, "Not equal" if they cannot be equal, and "Unknown" if both are still possible given the information so far.

Examples1

  1. Example 1

    Input
    6 8
    1 1 6
    2 1 1 6 6
    2 1 2 5 6
    2 1 3 5 6
    1 1 3
    2 1 3 4 6
    2 4 4 6 6
    2 2 3 4 5
    
    Expected output
    Equal
    Unknown
    Not equal
    Equal
    Equal
    Unknown