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)

class RangeUpdateQuery
  attr_reader :n, :dat, :lazy

  # @param [Integer] len 区間の長さ
  def initialize(len, init: -1)
    @n = 1

    @n *= 2 while @n < len
    @dat = Array.new(2 * @n - 1, init)
    @lazy = Array.new(2 * @n - 1)
  end

  # @param [Integer] l 更新範囲の左端
  # @param [Integer] r 更新範囲の右端
  # @param [Integer] x 更新する値
  def update(l, r, x)
    fill(l, r, x, 0, 0, n - 1)
  end

  # @param [Integer] idx 取得したい値の箇所
  def find(idx)
    sum(idx, idx, 0, 0, n - 1)
  end

  private

  # @param [Integer] a 探索範囲の左端
  # @param [Integer] b 探索範囲の右端
  # @param [Integer] x 更新する値
  # @param [Integer] idx 現在位置
  # @param [Integer] l 現在の探索範囲の左端
  # @param [Integer] r 現在の探索範囲の右端
  def fill(a, b, x, idx, l, r)
    return if r < a || b < l

    evaluate(idx, l, r)

    if a <= l && r <= b
      @lazy[idx] = x
    else
      fill(a, b, x, idx * 2 + 1, l, (l + r) / 2)
      fill(a, b, x, idx * 2 + 2, (l + r) / 2 + 1, r)
    end
  end

  def evaluate(idx, l, r)
    return if lazy[idx].nil?

    @dat[idx] = lazy[idx]

    if r - l > 0
      @lazy[2 * idx + 1] = lazy[idx]
      @lazy[2 * idx + 2] = lazy[idx]
    end

    @lazy[idx] = nil
  end

  def sum(a, b, idx, l, r)
    return 0 if r < a || b < l

    evaluate(idx, l, r)

    if a <= l && r <= b
      dat[idx]
    else
      vl = sum(a, b, idx * 2 + 1, l, (l + r) / 2)
      vr = sum(a, b, idx * 2 + 2, (l + r) / 2 + 1, r)

      vl + vr
    end
  end
end

N, Q = gets.split.map(&:to_i)
ruq = RangeUpdateQuery.new(N, init: 2 ** 31 - 1)

Q.times do
  query = gets.split.map(&:to_i)

  if query.first == 0
    _, s, t, n = *query
    ruq.update(s, t, n)
  else
    _, i = *query
    puts ruq.find(i)
  end
end