Under construction

Still being built. Things may change

Professional Fence Decorator

Time limit2sMemory limit1024 MB

Summary
Given n colored slats, process range repaint queries and report whether two equal-length fence segments have the same colors.
Level

Medium6 of 10

Topics
Segment tree, String matching
Solved
No attempts yet

Problem

Vasya is an apprentice at a well-known studio. He was recently assigned to help Vitezslav Smolokurov, a young fence decorator with great promise. The task is very important, and Vasya's future depends on how it goes.

Smolokurov's style is highly unusual, and his work is in great demand. The job has two stages. In the first stage, Vasya makes a blank: a long fence made of a row of colored vertical slats. In the second stage, Vitezslav starts working.

To give the fence a calmer, more harmonious look, he repeats the following operation several times: he picks a color and a segment, then repaints that segment in the chosen color. Smolokurov is creative and may change the design completely several times an hour, so he sometimes repaints the same slat more than once. He also does not want any pattern to repeat too often, so he sometimes checks whether one segment of the fence matches another.

Vasya does the repainting and the checking. The work is not easy, so Vasya asks for help, at least with the match checks.

Input

The first line contains one integer nn, the number of slats in the fence (1≤n≤100 0001 \le n \le 100\,000). The second line contains nn integers separated by spaces, the colors of the slats.

The third line contains one integer mm, the number of comparison and repaint tasks (1≤m≤100 0001 \le m \le 100\,000). Each of the next mm lines contains four integers qq, ll, rr, and kk.

For a repaint, q=0q = 0. It means repainting all slats from ll to rr inclusive to color kk (1≤l≤r≤n1 \le l \le r \le n). For a comparison, q=1q = 1. It means comparing the fence pieces of length kk that start at positions ll and rr (1≤l,r≤n−k+11 \le l, r \le n - k + 1, k>0k > 0).

All numbers in the input are positive and do not exceed 100 000100\,000.

Output

Output one line. For each comparison query, print <<+>> if the two pieces match and <<->> otherwise.

Examples2

  1. Example 1

    Input
    7
    1 2 1 3 1 2 1
    3
    0 4 5 2
    1 3 1 2
    1 3 1 3
    
    Expected output
    +-
    
  2. Example 2

    Input
    2
    1 2
    5
    1 1 2 1
    0 2 2 1
    1 1 2 1
    0 1 2 3
    1 1 1 2
    
    Expected output
    -++