Problem:
Range Update Query (RUQ)

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

update(s, t, x): change as, as+1, ..., at to x.

find(i): output the value of ai.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 i

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).

Output

For each find operation, print the value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

0 ≤ s ≤ t < n

0 ≤ i < n

0 ≤ x < 231−1

Sample Input 1

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0
1 1

Sample Output 1

1
3

Sample Input 2

1 3
1 0
0 0 0 5
1 0

Sample Output 2

2147483647
5

Solution in Ruby (judge verdict: Accepted)

def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
def min(a,b)
  return a>b ? b : a
end
class SD
  attr_accessor:data,:n,:n_sqrt,:lazy,:lazyF
  def initialize(n)
    @n_sqrt=(n**0.5).to_i
    @n=(n+@n_sqrt-1)/@n_sqrt
    @data=array(@n*@n_sqrt,1,2**31-1)
    @lazy=array(@n,1,0)
    @lazyF=array(@n,1,false) 
  end

  def lazy_eval(i)
    if @lazyF[i]
      @lazyF[i]=false
      @n_sqrt.times do|k|
        @data[i*@n_sqrt+k]=@lazy[i]
      end
    end
  end
  def update(s,t,x)
    @n.times do|i|
      l=i*@n_sqrt
      r=l+@n_sqrt
      next if r<=s or t<=l
      if s<=l and r<=t
        @lazy[i]=x
        @lazyF[i]=true
      else
        lazy_eval(i)
        for j in max(s,l)..min(t,r)-1
          @data[j]=x
        end
      end
    end
  end

  def find(i)
    lazy_eval(i/@n_sqrt)
    return @data[i] 
  end
end
n,q=get_i
sd=SD.new(n)
q.times do
  que=get_i
  case que[0]
  when 0 then
    s=que[1]
    t=que[2]
    x=que[3]
    sd.update(s,t+1,x)
  when 1 then
    puts sd.find(que[1])
  end
end