# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
import math

def check(val, div, pow):
    return val % (div ** pow) == 0

def count(val, div):
    if val % div == 0:
        lo, hi = 1, 0 if val <= 0 else int(math.log(val, div) + 1)
        while lo <= hi:
            m = (lo + hi) // 2
            if check(val, div, m):
                lo = m + 1
            else:
                hi = m - 1

        return hi

    return 0

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def count(val, div):
    c = 0
    while val % div == 0:
        val //= div
        c += 1
    return c

def solved(A, N, div):
    dp = [[1000 for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
import math

def check(val, div, pow):
    return val % (div ** pow) == 0

def count(val, div):
    if val % div == 0:
        lo, hi = 1, 0 if val <= 0 else int(math.log(val, div) + 1)
        while lo <= hi:
            m = (lo + hi) // 2
            if check(val, div, m):
                lo = m + 1
            else:
                hi = m - 1

        return hi

    return 0

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def haszero():
    for r in range(N):
        for c in range(N):
            if A[r][c] == 0:
                return True, r, c
    return False, -1, -1

def solve(A, N):
    aa, b = solved(A, N, 2)
    ac, d = solved(A, N, 5)

    h, r, c = haszero()
    if h and min(aa, ac) > 1:
        print(1)
        path = []
        for i in range(r):
            path.append('D')
        for i in range(c):
            path.append('R')
        for i in range(r, N-1):
            path.append('D')
        for i in range(c, N-1):
            path.append('R')
        print(''.join(path))

    elif aa < ac:
        print(aa)
        print(b)
    else:
        print(ac)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def check(val, div, pow):
    return val % (div ** pow) == 0

def count(val, div):
    if val % div == 0:
        lo, hi = 1, 64
        while lo <= hi:
            m = (lo + hi) // 2
            if check(val, div, m):
                lo = m + 1
            else:
                hi = m - 1

        return hi

    return 0

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)

def count(val, div):
    c = 0
    while val % div == 0:
        val //= div
        c += 1
    return c

def solve(div):
    dp = [[1000 for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r > 0 or c > 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1])

a, b = solve(2)
c, d = solve(5)
if a < c:
    print(a)
    print(b)
else:
    print(c)
    print(d)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
import math

def check(val, div, pow):
    return val % (div ** pow) == 0

def count(val, div):
    if val % div == 0:
        lo, hi = 1, int(math.log(val, div) + 1)
        while lo <= hi:
            m = (lo + hi) // 2
            if check(val, div, m):
                lo = m + 1
            else:
                hi = m - 1

        return hi

    return 0

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

def check(val, div, pow):
    return val % (div ** pow) == 0

def count(val, div):
    if val % div == 0:
        lo, hi = 1, 31
        while lo <= hi:
            m = (lo + hi) // 2
            if check(val, div, m):
                lo = m + 1
            else:
                hi = m - 1

        return hi

    return 0

def solved(A, N, div):
    dp = [[float('inf') for _ in range(N)] for _ in range(N)]
    pre = [['' for _ in range(N)] for _ in range(N)]
    dp[0][0] = count(A[0][0], div)
    for r in range(N):
        for c in range(N):
            dc = count(A[r][c], div)
            if r > 0 and dp[r-1][c] + dc < dp[r][c]:
                dp[r][c] = dp[r-1][c] + dc
                pre[r][c] = 'U'
            if c > 0 and dp[r][c-1] + dc < dp[r][c]:
                pre[r][c] = 'L'
                dp[r][c] = dp[r][c-1] + dc

    path = []
    r, c = N-1, N-1
    while r >= 0 and c >= 0:
        if pre[r][c] == 'U':
            path.append('D')
            r, c = r-1, c
        else:
            path.append('R')
            r, c = r, c-1

    return dp[N-1][N-1], ''.join(path[::-1][1:])

def solve(A, N):
    a, b = solved(A, N, 2)
    c, d = solved(A, N, 5)
    if a < c:
        print(a)
        print(b)
    else:
        print(c)
        print(d)

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)
solve(A, N)

# import random
# while True:
#     N = 1000
#     A = []
#     for i in range(N):
#         row = [random.randint(0, 10 ** 9) for _ in range(N)]
#         A.append(row)
#     solve(A, N)


# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 1/3/20

"""

import collections
import time
import os
import sys
import bisect
import heapq
from typing import List

N = int(input())
A = []
for i in range(N):
    row = [int(x) for x in input().split()]
    A.append(row)

dp = [[1000 for _ in range(N)] for _ in range(N)]
dp25 = [[[1000, 1000] for _ in range(N)] for _ in range(N)]
dp52 = [[[1000, 1000] for _ in range(N)] for _ in range(N)]

pre25 = [[None for _ in range(N)] for _ in range(N)]
pre52 = [[None for _ in range(N)] for _ in range(N)]
pre = [[(-1, -1) for _ in range(N)] for _ in range(N)]

def defact(v):
    zero = 0
    while v % 10 == 0:
        zero += 1
        v //= 10
    two = 0
    while v % 2 == 0:
        v //= 2
        two += 1
    five = 0
    while v % 5 == 0:
        v //= 5
        five += 1

    return zero, two, five

z, t, f = defact(A[0][0])
dp[0][0] = z
dp25[0][0] = [t, f]
dp52[0][0] = [f, t]

for r in range(N):
    for c in range(N):
        z, t, f = defact(A[r][c])

        q = []
        if r > 0:
            q.append(((r-1, c), [dp[r-1][c]] + dp25[r-1][c] + dp52[r-1][c]))
        if c > 0:
            q.append(((r, c-1), [dp[r][c-1]] + dp25[r][c-1] + dp52[r][c-1]))

        for (pr, pc), (prezero, pretwo, prefive, pretwo2, prefive2) in q:

            z1 = min(t+pretwo, f+prefive)
            z2 = min(t+pretwo2, f + prefive2)
            zadd = min(z1, z2)

            newzero = z + prezero + zadd
            if newzero <= dp[r][c]:
                pre[r][c] = (pr, pc)
                dp[r][c] = newzero
                if pretwo < pretwo2 or (pretwo == pretwo2 and prefive < prefive2):
                    if t+pretwo-zadd < dp25[r][c][0] or (t+pretwo-zadd == dp25[r][c][0] and f+prefive-zadd < dp25[r][c][1]):
                        dp25[r][c][0] = t+pretwo-zadd
                        dp25[r][c][1] = f+prefive-zadd
                else:
                    if t+pretwo2-zadd < dp25[r][c][0] or (t+pretwo2-zadd == dp25[r][c][0] and +prefive2-zadd < dp25[r][c][1]):
                        dp25[r][c][0] = t+pretwo2-zadd
                        dp25[r][c][1] = f+prefive2-zadd

                if prefive < prefive2 or (prefive == prefive2 and pretwo < pretwo2):
                    if t + prefive - zadd < dp52[r][c][1] or (t + prefive - zadd == dp52[r][c][1] and t + pretwo - zadd < dp52[r][c][0]):
                        dp52[r][c][0] = t + pretwo - zadd
                        dp52[r][c][1] = f + prefive - zadd
                else:
                    if f + prefive2 - zadd < dp52[r][c][1] or (f + prefive2 - zadd == dp52[r][c][1] and t + pretwo2 - zadd < dp52[r][c][0]):
                        dp52[r][c][0] = t + pretwo2 - zadd
                        dp52[r][c][1] = f + prefive2 - zadd

# for row in dp:
#     print(row)
# print('#' * 40)
#
# for row in dp25:
#     print(row)
# print('#' * 40)
#
# for row in dp52:
#     print(row)
# print('#' * 40)
#
# for row in pre:
#     print(row)
# print('#' * 40)

print(dp[N-1][N-1])

r, c = N-1, N-1
path = []
while r >= 0 and c >= 0:
    pr, pc = pre[r][c]
    # print(r, c)
    if pr == r:
        path.append('R')
    else:
        path.append('D')
    r, c = pr, pc

print(''.join(path[::-1][1:]))


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns, tc):
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      up = abs(tc[i-1][j])
      left = abs(tc[i][j-1])
      if (max(up, left) >= MAX_ZEROS or min(tc[i-1][j], tc[i][j-1]) == -1) and min(up, left) + tc[i][j] > 0:
        tc[i][j] = -1
        if up >= MAX_ZEROS:
          tc[i-1][j] = -1
        elif left >= MAX_ZEROS:
          tc[i][j-1] = -1
      else:
        tc[i][j] = min(up, left) + tc[i][j]

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  if abs(factor_2[n-1][n-1]) <= abs(factor_5[n-1][n-1]):
    sys.stdout.write(str(abs(factor_2[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(str(abs(factor_5[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns, tc):
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      up = abs(tc[i-1][j])
      left = abs(tc[i][j-1])
      if (max(up, left) >= MAX_ZEROS or min(tc[i-1][j], tc[i][j-1]) == -1) and min(up, left) + tc[i][j] > 0:
        tc[i][j] = -1
        if up >= MAX_ZEROS:
          tc[i-1][j] = -1
        elif left >= MAX_ZEROS:
          tc[i][j-1] = -1
      else:
        tc[i][j] = min(up, left) + tc[i][j]

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if abs(tc[row_idx][column_idx-1]) > abs(tc[row_idx-1][column_idx]):
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  if abs(factor_2[n-1][n-1]) <= abs(factor_5[n-1][n-1]):
    sys.stdout.write(str(abs(factor_2[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(str(abs(factor_5[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)
  num_factor_2 = 0
  num_factor_5 = 0
  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    num_factor_2 += 1
  while num%5==0:
    num = num//5
    num_factor_5 += 1
  factor_2[row][col] = num_factor_2
  factor_5[row][col] = num_factor_5

def total_cost(rows, columns, tc):
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      tc[i][j] = min(tc[i-1][j],tc[i][j-1]) + tc[i][j]

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx += -1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx += -1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx += -1
    else:
      moves += 'R'
      column_idx += -1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  if factor_2[n-1][n-1] <= factor_5[n-1][n-1]:
    sys.stdout.write(str(factor_2[n-1][n-1]) + '\n')
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(str(factor_5[n-1][n-1]) + '\n')
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns, tc):
  multiply_by_0 = 0
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      if min(tc[i-1][j],tc[i][j-1]) > 0 and max(tc[i-1][j],tc[i][j-1]) == MAX_ZEROS:
        multiply_by_0 = 1
      if not multiply_by_0:
        tc[i][j] = min(tc[i-1][j],tc[i][j-1]) + tc[i][j]
      else:
        tc[i][j] = multiply_by_0

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  num_zeros = min(factor_2[n-1][n-1],factor_5[n-1][n-1])
  num_zeros = num_zeros if num_zeros >= 0 else 1
  sys.stdout.write(str(num_zeros) + '\n')
  if factor_2[n-1][n-1] <= factor_5[n-1][n-1]:
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns, tc):
  multiply_by_0 = 0
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      if not multiply_by_0 and min(tc[i-1][j],tc[i][j-1]) > 0 and max(tc[i-1][j],tc[i][j-1]) == MAX_ZEROS:
        multiply_by_0 = 1
      if not multiply_by_0:
        tc[i][j] = min(tc[i-1][j],tc[i][j-1]) + tc[i][j]
      else:
        tc[i][j] = multiply_by_0

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  num_zeros = min(factor_2[n-1][n-1],factor_5[n-1][n-1])
  sys.stdout.write(str(num_zeros) + '\n')
  if factor_2[n-1][n-1] <= factor_5[n-1][n-1]:
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns, tc):
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      up = abs(tc[i-1][j])
      left = abs(tc[i][j-1])
      multiply_by_0 = 0
      if (max(up, left) >= MAX_ZEROS or min(tc[i-1][j], tc[i][j-1]) == -1) and min(up, left) > 0:
        multiply_by_0 = -1
        if up >= MAX_ZEROS:
          tc[i-1][j] = multiply_by_0
        elif left >= MAX_ZEROS:
          tc[i][j-1] = multiply_by_0

      if not multiply_by_0:
        tc[i][j] = min(up, left) + tc[i][j]
      else:
        tc[i][j] = multiply_by_0

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  if abs(factor_2[n-1][n-1]) <= abs(factor_5[n-1][n-1]):
    sys.stdout.write(str(abs(factor_2[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(str(abs(factor_5[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = n

  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    factor_2[row][col] += 1
  while num%5==0:
    num = num//5
    factor_5[row][col] += 1

def total_cost(rows, columns):
  for i in range(1, rows):
    for tc in factors:
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
    for tc in factors:
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      for tc in factors:
        up = abs(tc[i-1][j])
        left = abs(tc[i][j-1])
        if (max(up, left) >= MAX_ZEROS or min(tc[i-1][j], tc[i][j-1]) == -1) and min(up, left) + tc[i][j] > 0:
          tc[i][j] = -1
          if up >= MAX_ZEROS:
            tc[i-1][j] = -1
          elif left >= MAX_ZEROS:
            tc[i][j-1] = -1
        else:
          tc[i][j] = min(up, left) + tc[i][j]

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx -= 1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx -= 1
      continue
    if abs(tc[row_idx][column_idx-1]) > abs(tc[row_idx-1][column_idx]):
      moves += 'D'
      row_idx -= 1
    else:
      moves += 'R'
      column_idx -= 1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  global factors
  factors = [factor_2, factor_5]

  for row in range(n):
    for col, num in enumerate(map(int,sys.stdin.readline().strip().split())):
      if num%10 in {0,2,4,5,6,8}:
        factor_2_5(num, row, col)

  total_cost(n,n)

  if abs(factor_2[n-1][n-1]) <= abs(factor_5[n-1][n-1]):
    sys.stdout.write(str(abs(factor_2[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(str(abs(factor_5[n-1][n-1])) + '\n')
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


"""
Codeforces
2B - The least round way
http://codeforces.com/problemset/problem/2/B

Héctor González Belver
18/06/2018
"""
import sys

factor_5 = []
factor_2= []
MAX_ZEROS = 20000

def factor_2_5(n, row, col):
  num = int(n)
  num_factor_2 = 0
  num_factor_5 = 0
  if num == 0:
    factor_2[row][col] = MAX_ZEROS
    factor_5[row][col] = MAX_ZEROS
    return
  while num%2==0:
    num = num//2
    num_factor_2 += 1
  while num%5==0:
    num = num//5
    num_factor_5 += 1
  factor_2[row][col] = num_factor_2
  factor_5[row][col] = num_factor_5

def total_cost(rows, columns, tc):
  for i in range(1, rows):
      tc[i][0] = tc[i-1][0] + tc[i][0]

  for j in range(1, columns):
      tc[0][j] = tc[0][j-1] + tc[0][j]

  for i in range(1, rows):
    for j in range(1, columns):
      tc[i][j] = min(tc[i-1][j],tc[i][j-1]) + tc[i][j]

def min_path(rows, columns, tc):
  row_idx = rows-1
  column_idx = columns-1

  moves = ''
  for _ in range(row_idx + column_idx):
    if row_idx == 0:
      moves += 'R'
      column_idx += -1
      continue
    if column_idx == 0:
      moves += 'D'
      row_idx += -1
      continue
    if tc[row_idx][column_idx-1]>tc[row_idx-1][column_idx]:
      moves += 'D'
      row_idx += -1
    else:
      moves += 'R'
      column_idx += -1

  return moves[::-1]

def main():
  n = int(sys.stdin.readline().strip())

  global factor_2
  global factor_5
  factor_2 = [[0]*n for j in range(n)]
  factor_5 = [[0]*n for j in range(n)]

  for row in range(n):
    for col, num in enumerate(sys.stdin.readline().strip().split()):
      factor_2_5(num, row, col)

  total_cost(n,n, factor_2)
  total_cost(n,n, factor_5)

  num_zeros = min(factor_2[n-1][n-1],factor_5[n-1][n-1])
  num_zeros = num_zeros if num_zeros < MAX_ZEROS else 1
  sys.stdout.write(str(num_zeros) + '\n')
  if factor_2[n-1][n-1] <= factor_5[n-1][n-1]:
    sys.stdout.write(min_path(n,n,factor_2) + '\n')
  else:
    sys.stdout.write(min_path(n,n,factor_5) + '\n')

if __name__ == '__main__':
  main()


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=550;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;

		if(l!=xr){
			if(a[l].F==qval-toadd[xl]){
				R=a[l].S;
				if(L==-1){
					L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
				}
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=650;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;
		if(l!=xr && a[l].F==qval-toadd[xl]){
			R=a[l].S;
			if(L==-1){
				L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=700;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;
		if(l!=xr && a[l].F==qval-toadd[xl]){
			R=a[l].S;
			if(L==-1){
				L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=700;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)
					a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;
		if(l+1!=xl && a[l].F==qval-toadd[xl]){
			R=a[l].S;
			if(L==-1){
				L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}
	}
	cout<<"\n";
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

const int N=5e5+100;
const int SQ=700;

int n,toadd[N];
pair<int,int> a[N];

void relax(int xl,int xr){
	for(int i=xl;i<xr;i++){
		a[i].F+=toadd[xl];
	}
	sort(a+xl,a+xr);
	toadd[xl]=0;
}
void build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]+=qval;
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F+=qval;
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;
		if(l!=xr){
			if(a[l].F==qval){
				R=a[l].S;
				if(L==-1){
					L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1LL))->S;
				}
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

const int N=5e5+100;
const int SQ=700;

int n,toadd[N];
pair<int,int> a[N];

void relax(int xl,int xr){
	for(int i=xl;i<xr;i++){
		a[i].F+=toadd[xl];
	}
	sort(a+xl,a+xr);
	toadd[xl]=0;
}
void build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]+=qval;
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F+=qval;
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;

		if(l!=xr){
			if(a[l].F==qval-toadd[xl]){
				R=a[l].S;
				if(L==-1){
					L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1LL))->S;
				}
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=700;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;

		if(l!=xr){
			if(a[l].F==qval-toadd[xl]){
				R=a[l].S;
				if(L==-1){
					L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
				}
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

const int N=5e5+100;
const int SQ=700;
const int inf=1e9+100;

int n,toadd[N];
pair<int,int> a[N];

void inline relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void inline build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]=min(inf,qval+toadd[xl]);
		}else if(min(qr,xr)-max(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)
					a[i].F=min(inf,a[i].F+qval);
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;
		if(l+1!=xl && a[l].F==qval-toadd[xl]){
			R=a[l].S;
			if(L==-1){
				L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1))->S;
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}
	}
	cout<<"\n";
	return 0;
}


//In the name of Allah
#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

const int N=5e5+100;
const int SQ=700;

int n,toadd[N];
pair<int,int> a[N];

void relax(int xl,int xr){
	sort(a+xl,a+xr);
}
void build(){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		relax(xl,xr);
	}
}

void add(int ql,int qr,int qval){
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		if(xl>=ql && xr<=qr){
			toadd[xl]+=qval;
		}else if(max(qr,xr)-min(ql,xl)>0){
			for(int i=xl;i<xr;i++){
				if(a[i].S>=ql && a[i].S<qr)a[i].F+=qval;
			}
			relax(xl,xr);
		}
	}
}
int get(int qval){
	int L=-1,R=-1;
	for(int xl=0;xl<n;xl+=SQ){
		int xr=min(xl+SQ,n);
		int l=upper_bound(a+xl,a+xr,MP(qval-toadd[xl],N))-a;
		l--;

		if(l!=xr){
			if(a[l].F==qval-toadd[xl]){
				R=a[l].S;
				if(L==-1){
					L=lower_bound(a+xl,a+xr,MP(qval-toadd[xl],-1LL))->S;
				}
			}
		}
	}
	if(L==-1)return -1;
	return R-L;
}

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);
	int q;
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a[i].F;
		a[i].S=i;
	}
	build();

	for(int _=0,t,l,r,val,x;_<q;_++){
		cin>>t;
		if(t==1){
			cin>>l>>r>>val;
			add(l-1,r,val);
		}else{
			cin>>x;
			cout<<get(x)<<"\n";
		}

	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=720;
unordered_map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
}
void upd(int l,int r,long long x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    recalc(x1);
    recalc(x2);
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mi1==-1 && mn[i].count(y-lazy[i]))
            mi1=mn[i][y-lazy[i]];
        if(mx[i].count(y-lazy[i]))
            mi2=mx[i][y-lazy[i]];
    }
    return mi2-mi1;
}
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        scanf("%d",&t);
        if(t==1){
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            scanf("%d",&y);
            printf("%d\n",query(y));
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=850;
map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
}
void upd(int l,int r,long long x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    recalc(x1);
    recalc(x2);
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mi1==-1 && mn[i].count(y-lazy[i]))
            mi1=mn[i][y-lazy[i]];
        if(mx[i].count(y-lazy[i]))
            mi2=mx[i][y-lazy[i]];
    }
    return mi2-mi1;
}
int main()
{
    ios::sync_with_stdio(0);
    int q;
    cin>>n>>q;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            int l,r,x;
            cin>>l>>r>>x;
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            cin>>y;
            cout<<query(y)<<endl;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=720;
unordered_map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
}
void upd(int l,int r,long long x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    recalc(x1);
    recalc(x2);
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mn[i].count(y-lazy[i])){
            mi1=mn[i][y-lazy[i]];
            break;
        }
    }
    if(mi1!=-1){
        for(int i=SQ-1;i>=0;i--){
            if(mx[i].count(y-lazy[i])){
                mi2=mx[i][y-lazy[i]];
                break;
            }
        }
    }
    return mi2-mi1;
}
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        scanf("%d",&t);
        if(t==1){
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            scanf("%d",&y);
            printf("%d\n",query(y));
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=720;
map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
}
void upd(int l,int r,long long x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    recalc(x1);
    recalc(x2);
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mi1==-1 && mn[i].count(y-lazy[i]))
            mi1=mn[i][y-lazy[i]];
        if(mx[i].count(y-lazy[i]))
            mi2=mx[i][y-lazy[i]];
    }
    return mi2-mi1;
}
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        scanf("%d",&t);
        if(t==1){
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            scanf("%d",&y);
            printf("%d\n",query(y));
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=850;
unordered_map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
}
void upd(int l,int r,int x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    recalc(x1);
    recalc(x2);
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mn[i].count(y-lazy[i])){
            mi1=mn[i][y-lazy[i]];
            break;
        }
    }
    if(mi1!=-1){
        for(int i=SQ-1;i>=0;i--){
            if(mx[i].count(y-lazy[i])){
                mi2=mx[i][y-lazy[i]];
                break;
            }
        }
    }
    return mi2-mi1;
}
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        scanf("%d",&t);
        if(t==1){
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            scanf("%d",&y);
            printf("%d\n",query(y));
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
const int MN=500*1000+500;
const int SQ=710;
unordered_map<long long,int> mn[SQ],mx[SQ];
long long lazy[SQ];
bool mark[SQ];
long long a[MN];
int n;
void recalc(int p){
    mn[p].clear();
    mx[p].clear();
    for(int i=p*SQ;i<(min((p+1)*SQ,n));i++){
        a[i]+=lazy[p];
        if(!mn[p].count(a[i]))
            mn[p][a[i]]=i;
        mx[p][a[i]]=i;
    }
    lazy[p]=0;
    mark[p]=false;
}
void upd(int l,int r,int x){
    int x1=l/SQ,x2=r/SQ;
    while(l%SQ && l<r)
        a[l++]+=x;
    while(r%SQ && l<r)
        a[--r]+=x;
    mark[x1]=true;
    mark[x2]=true;
    for(int i=l/SQ;i<r/SQ;i++){
        lazy[i]+=x;
    }
}
int query(long long y){
    int mi1=-1,mi2=-2;
    for(int i=0;i<SQ;i++){
        if(mark[i])
            recalc(i);
        if(mn[i].count(y-lazy[i])){
            mi1=mn[i][y-lazy[i]];
            break;
        }
    }
    if(mi1!=-1){
        for(int i=SQ-1;i>=0;i--){
            if(mark[i])
                recalc(i);
            if(mx[i].count(y-lazy[i])){
                mi2=mx[i][y-lazy[i]];
                break;
            }
        }
    }
    return mi2-mi1;
}
int main()
{
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<SQ;i++)
        recalc(i);
    for(int i=0;i<q;i++){
        int t;
        scanf("%d",&t);
        if(t==1){
            int l,r,x;
            scanf("%d%d%d",&l,&r,&x);
            l--;
            upd(l,r,x);
        }
        else{
            int y;
            scanf("%d",&y);
            printf("%d\n",query(y));
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int n, q, a[500005], bl[500005], len, add[500005], opt, l, r, x;
vector<int> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (bl[x] - 1) * len + 1; i <= bl[x] * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%d", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += x;
        }else {
            scanf("%d", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == x) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == x) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            if(Min == INT_MAX && Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, q, bl[500005], len, opt, l, r, x;
LL a[500005], add[500005]
vector<LL> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (x - 1) * len + 1; i <= x * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    //cout << num << endl;
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    // for(int i = 1; i <= num; ++i) {
    //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
    // }
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%d", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += 1LL * x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                //cout << (bl[r] - 1) * len + 1 << " " << r << endl;
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += 1LL * x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += 1LL * x;
            // cout << "rebuild" << endl;
            // for(int i = 1; i <= num; ++i) {
            //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
            // }
            // cout << endl;
        }else {
            scanf("%d", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == 1LL * x - add[i]) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == 1LL * x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                //cout << "right " << " num = " << i << " : " << p << endl;
                //for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " "; cout << endl;
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == 1LL * x - add[i]) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == 1LL * x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            // for(int i = 1; i <= n; ++i) {
            //     cout << a[i] << " ";
            // }cout << endl;
            // for(int i = 1; i <= num; ++i) cout << add[i] << " "; cout << endl;
            // cout << Min << " " << Max << endl;
            if(Min == INT_MAX || Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, q, a[500005], bl[500005], len, add[500005], opt, l, r, x;
vector<int> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (x - 1) * len + 1; i <= x * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    //cout << num << endl;
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    // for(int i = 1; i <= num; ++i) {
    //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
    // }
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%d", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                //cout << (bl[r] - 1) * len + 1 << " " << r << endl;
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += x;
            // cout << "rebuild" << endl;
            // for(int i = 1; i <= num; ++i) {
            //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
            // }
            // cout << endl;
        }else {
            scanf("%d", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == x - add[i]) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                //cout << "right " << " num = " << i << " : " << p << endl;
                //for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " "; cout << endl;
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == x - add[i]) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            // for(int i = 1; i <= n; ++i) {
            //     cout << a[i] << " ";
            // }cout << endl;
            // for(int i = 1; i <= num; ++i) cout << add[i] << " "; cout << endl;
            // cout << Min << " " << Max << endl;
            if(Min == INT_MAX && Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, q, bl[500005], len, opt, l, r, x;
LL a[500005], add[500005];
vector<LL> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (x - 1) * len + 1; i <= x * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    //cout << num << endl;
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    // for(int i = 1; i <= num; ++i) {
    //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
    // }
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%d", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += 1LL * x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                //cout << (bl[r] - 1) * len + 1 << " " << r << endl;
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += 1LL * x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += 1LL * x;
            // cout << "rebuild" << endl;
            // for(int i = 1; i <= num; ++i) {
            //     for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " ";cout << endl;
            // }
            // cout << endl;
        }else {
            scanf("%d", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == 1LL * x - add[i]) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == 1LL * x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                int p = lower_bound(pre[i].begin(), pre[i].end(), x - add[i]) - pre[i].begin();
                //cout << "right " << " num = " << i << " : " << p << endl;
                //for(int j = 0; j < pre[i].size(); ++j) cout << pre[i][j] << " "; cout << endl;
                if(p >= pre[i].size()) continue;
                if(pre[i][p] == 1LL * x - add[i]) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == 1LL * x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            // for(int i = 1; i <= n; ++i) {
            //     cout << a[i] << " ";
            // }cout << endl;
            // for(int i = 1; i <= num; ++i) cout << add[i] << " "; cout << endl;
            // cout << Min << " " << Max << endl;
            if(Min == INT_MAX || Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, q, bl[500005], len, opt, l, r;
LL a[500005], add[500005], x;
vector<LL> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (x - 1) * len + 1; i <= x * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%lld", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += x;
        }else {
            scanf("%lld", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                if(find(pre[i].begin(), pre[i].end(), x - add[i]) != pre[i].end()) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                if(find(pre[i].begin(), pre[i].end(), x - add[i]) != pre[i].end()) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            if(Min == INT_MAX || Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, q, bl[500005], len, opt, l, r;
LL a[500005], add[500005], x;
vector<LL> pre[500005];
inline void rebuild(int x) {
    pre[x].clear();
    for(int i = (x - 1) * len + 1; i <= x * len; ++i) pre[x].push_back(a[i]);
    sort(pre[x].begin(), pre[x].end());
}
int main() {
    scanf("%d%d", &n, &q); len = (int) sqrt(n * 1.0);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]); bl[i] = (i - 1) / len + 1; pre[bl[i]].push_back(a[i]);
    }
    int num = n / len + (n % len ? 1 : 0);
    for(int i = 1; i <= num; ++i) sort(pre[i].begin(), pre[i].end());
    while(q--) {
        scanf("%d", &opt);
        if(opt == 1) {
            scanf("%d%d%lld", &l, &r, &x);
            for(int i = l; i <= min(r, bl[l] * len); ++i) a[i] += x; rebuild(bl[l]);
            if(bl[l] != bl[r]) {
                for(int i = (bl[r] - 1) * len + 1; i <= r; ++i) a[i] += x; rebuild(bl[r]);
            }
            for(int i = bl[l] + 1; i < bl[r]; ++i) add[i] += x;
        }else {
            scanf("%lld", &x); int Min = INT_MAX, Max = -INT_MAX;
            for(int i = 1; i <= num; ++i) {
                if(binary_search(pre[i].begin(), pre[i].end(), x - add[i])) {
                    for(int j = (i - 1) * len + 1; j <= i * len; ++j) {
                        if(a[j] + add[i] == x) {
                            Min = j; break;
                        }
                    }
                    break;
                }
            }
            for(int i = num; i >= 1; --i) {
                if(binary_search(pre[i].begin(), pre[i].end(), x - add[i])) {
                    for(int j = i * len; j >= (i - 1) * len + 1; --j) {
                        if(a[j] + add[i] == x) {
                            Max = j; break;
                        }
                    }
                    break;
                }
            }
            if(Min == INT_MAX || Max == -INT_MAX) printf("-1\n");
            else printf("%d\n", Max - Min);
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int f[1004], e[1004], pl[1004];
pii ara[mx*2];

int32_t main(){
    //read();
    fst;
    int n, q;
    cin >> n >> q;
    int sq = sqrt(n);
    int inc = (n+sq-1)/sq;
    for(int i=1;i<=n;i++) {
        cin >> ara[i].fi;
        ara[i].se = i;
    }
    int beg = 1;
    int en = inc+1;
    for(int i=0;i<=sq;i++){
        sort(ara+beg, ara+en);
        beg = en;
        en += inc;
        if(beg>n) break;
        en = min(n+1, en);
    }
    while(q--){
        int t;
        cin >> t;
        if(t==1){
            int l, r, x;
            cin >> l >> r >> x;
            beg = 1;
            en = inc+1;
            for(int i=0;i<=sq;i++){
                if(r<beg || en<=l) {}
                else if(l<=beg && r>en){
                    pl[i] += x;
                }
                else{
                    for(int j=beg;j<en;j+=1){
                        if(ara[j].se>=l&&ara[j].se<=r) ara[j].fi += x;
                    }
                    sort(ara+beg, ara+en);
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
        }
        else{
            int y;
            cin >> y;
            int tmp[] = {-1, -1};
            beg = 1;
            en = inc + 1;
            for(int i=0;i<=sq;i++){
                pii tst = {y - pl[i], -1};
                pii tst2 = {y - pl[i], n+2};
                int l = lower_bound(ara+beg, ara+en, tst) - ara;
                //cout << i << " " << l << endl;
                int r = upper_bound(ara+beg, ara+en, tst2) - ara;
                if(l != en && ara[l].fi + pl[i] == y){
                    if(tmp[0]==-1) tmp[0] = ara[l].se;
                    tmp[1] = ara[r-1].se;
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
            if(tmp[0]==-1) cout << -1 << endl;
            else cout << tmp[1] - tmp[0] << endl;
        }
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int f[1004], e[1004], pl[1004];
pii ara[mx*2];

int32_t main(){
    //read();
    //fst;
    int n, q;
    cin >> n >> q;
    int sq = sqrt(n);
    int inc = (n+sq-1)/sq;
    for(int i=1;i<=n;i++) {
        cin >> ara[i].fi;
        ara[i].se = i;
    }
    int beg = 1;
    int en = inc+1;
    for(int i=0;i<=sq;i++){
        sort(ara+beg, ara+en);
        beg = en;
        en += inc;
        if(beg>n) break;
        en = min(n+1, en);
    }
    while(q--){
        int t;
        cin >> t;
        if(t==1){
            int l, r, x;
            cin >> l >> r >> x;
            beg = 1;
            en = inc+1;
            for(int i=0;i<=sq;i++){
                if(r<beg || en<=l) {}
                else if(l<=beg && r>en){
                    pl[i] += x;
                }
                else{
                    for(int j=beg;j<en;j+=1){
                        if(ara[j].se>=l&&ara[j].se<=r) ara[j].fi += x;
                    }
                    sort(ara+beg, ara+en);
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
        }
        else{
            int y;
            cin >> y;
            int tmp[] = {-1, -1};
            beg = 1;
            en = inc + 1;
            for(int i=0;i<=sq;i++){
                pii tst = {y - pl[i], -1};
                pii tst2 = {y - pl[i], n+2};
                int l = lower_bound(ara+beg, ara+en, tst) - ara;
                //cout << i << " " << l << endl;
                int r = upper_bound(ara+beg, ara+en, tst2) - ara;
                if(l != en && ara[l].fi + pl[i] == y){
                    if(tmp[0]==-1) tmp[0] = ara[l].se;
                    tmp[1] = ara[r-1].se;
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
            if(tmp[0]==-1) cout << -1 << endl;
            else cout << tmp[1] - tmp[0] << endl;
        }
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int f[1004], e[1004], pl[1004];
pii ara[mx*2];

int32_t main(){
    //read();
    //fst;
    int n, q;
    scanf("%lld%lld", &n, &q);
    int sq = sqrt(n);
    int inc = (n+sq-1)/sq;
    for(int i=1;i<=n;i++) {
        scanf("%lld", &ara[i].fi);
        ara[i].se = i;
    }
    int beg = 1;
    int en = inc+1;
    for(int i=0;i<=sq;i++){
        sort(ara+beg, ara+en);
        beg = en;
        en += inc;
        if(beg>n) break;
        en = min(n+1, en);
    }
    while(q--){
        int t;
        scanf("%lld", &t);
        if(t==1){
            int l, r, x;
            scanf("%lld%lld%lld", &l, &r, &x);
            beg = 1;
            en = inc+1;
            for(int i=0;i<=sq;i++){
                if(r<beg || en<=l) {}
                else if(l<=beg && r>en){
                    pl[i] += x;
                }
                else{
                    for(int j=beg;j<en;j+=1){
                        if(ara[j].se>=l&&ara[j].se<=r) ara[j].fi += x;
                    }
                    sort(ara+beg, ara+en);
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
        }
        else{
            int y;
            scanf("%lld", &y);
            int tmp[] = {-1, -1};
            beg = 1;
            en = inc + 1;
            for(int i=0;i<=sq;i++){
                pii tst = {y - pl[i], -1};
                pii tst2 = {y - pl[i], n+2};
                int l = lower_bound(ara+beg, ara+en, tst) - ara;
                //cout << i << " " << l << endl;
                int r = upper_bound(ara+beg, ara+en, tst2) - ara;
                if(l != en && ara[l].fi + pl[i] == y){
                    if(tmp[0]==-1) tmp[0] = ara[l].se;
                    tmp[1] = ara[r-1].se;
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
            if(tmp[0]==-1) printf("-1\n");
            else printf("%lld\n", tmp[1] - tmp[0]);
        }
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int f[1004], e[1004], pl[1004];
pii ara[mx*2];

int32_t main(){
    //read();
    //fst;
    int n, q;
    cin >> n >> q;
    int sq = sqrt(n);
    int inc = (n+sq-1)/sq;
    for(int i=1;i<=n;i++) {
        cin >> ara[i].fi;
        ara[i].se = i;
    }
    int beg = 1;
    int en = inc+1;
    for(int i=0;i<=sq;i++){
        sort(ara+beg, ara+en);
        beg = en;
        en += inc;
        if(beg>n) break;
        en = min(n+1, en);
    }
    while(q--){
        int t;
        cin >> t;
        if(t==1){
            int l, r, x;
            cin >> l >> r >> x;
            beg = 1;
            en = inc+1;
            for(int i=0;i<=sq;i++){
                if(r<beg || en<=l) {}
                else if(l<=beg && r>en){
                    pl[i] += x;
                }
                else{
                    for(int j=beg;j<en;j+=1){
                        if(ara[j].se>=l&&ara[j].se<=r) ara[j].fi += x;
                    }
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
        }
        else{
            int y;
            cin >> y;
            int tmp[] = {-1, -1};
            beg = 1;
            en = inc + 1;
            for(int i=0;i<=sq;i++){
                pii tst = {y - pl[i], -1};
                pii tst2 = {y - pl[i], inf};
                int l = lower_bound(ara+beg, ara+en, tst) - ara;
                //cout << i << " " << l << endl;
                int r = upper_bound(ara+beg, ara+en, tst2) - ara;
                if(l != en && ara[l].fi + pl[i] == y){
                    if(tmp[0]==-1) tmp[0] = ara[l].se;
                    tmp[1] = ara[r-1].se;
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
            if(tmp[0]==-1) cout << -1 << endl;
            else cout << tmp[1] - tmp[0] << endl;
        }
    }
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mx 300005
#define int long long
#define pii pair <int, int>
#define piii pair <int, pii>
#define fi first
#define se second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define mem(ara, x) memset(ara, x, sizeof ara)
#define read() freopen("in.txt", "r", stdin)
#define write() freopen("out.txt", "w", stdout)
#define fst ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int f[1004], e[1004], pl[1004];
pii ara[mx*2];

int32_t main(){
    //read();
    //fst;
    int n, q;
    cin >> n >> q;
    int sq = sqrt(n);
    int inc = n/sq;
    for(int i=1;i<=n;i++) {
        cin >> ara[i].fi;
        ara[i].se = i;
    }
    int beg = 1;
    int en = inc+1;
    for(int i=1;i<=sq;i++){
        sort(ara+beg, ara+en);
        beg = en;
        en += inc;
        if(beg>n) break;
        en = min(n+1, en);
    }
    while(q--){
        int t;
        cin >> t;
        if(t==1){
            int l, r, x;
            cin >> l >> r >> x;
            beg = 1;
            en = inc+1;
            for(int i=1;i<=sq;i++){
                if(r<beg || en<=l) {}
                else if(l<=beg && r>en){
                    pl[i] += x;
                }
                else{
                    for(int j=beg;j<en;j+=1){
                        ara[j].fi += x;
                    }
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
        }
        else{
            int y;
            cin >> y;
            int tmp[] = {-1, -1};
            beg = 1;
            en = inc + 1;
            for(int i=1;i<=sq;i++){
                pii tst = {y - pl[i], -1};
                int l = lower_bound(ara+beg, ara+en, tst) - ara;
                int r = upper_bound(ara+beg, ara+en, tst) - ara;
                if(l !=en && ara[l].fi + pl[i] == y){
                    if(tmp[0]==-1) tmp[0] = ara[l].se;
                    tmp[1] = ara[r].se;
                }
                beg = en;
                en += inc;
                if(beg>n) break;
                en = min(n+1, en);
            }
            if(tmp[0]==-1) cout << -1 << endl;
            else cout << tmp[1] - tmp[0] << endl;
        }
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
void pre(){
	for(int j=1;j*len<=n;j++){
		for(int i=1;i<=len;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j*len<=n;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else if((j*len>=l&&(j-1)*len<=l)||((j-1)*len<=r&&(j*len>=r))||((j-1)*len>=l&&j*len<=r)){
					for(int i=0;i<len;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j*len<=n;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
void pre(){
	for(int j=1;j*len<=n;j++){
		for(int i=1;i<=len&&(j-1)*len+i<=n;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j*len<=n;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else if((j*len>=l&&(j-1)*len<=l)||((j-1)*len<=r&&(j*len>=r))||((j-1)*len>=l&&j*len<=r)){
					for(int i=0;i<len&&(j-1)*len+i<=n;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j*len<=n;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				sort(res.begin(),res.end());
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
void pre(){
	for(int j=1;j*len<=n;j++){
		for(int i=1;i<=len;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j*len<=n;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else if(j*len>=l||(j-1)*len<=r){
					for(int i=0;i<len;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j*len<=n;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
void pre(){
	for(int j=1;j*len<=n;j++){
		for(int i=1;i<=len;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j*len<=n;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else {
					for(int i=0;i<len;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j*len<=n;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
void pre(){
	for(int j=1;j*len<=n;j++){
		for(int i=1;i<=len;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j*len<=n;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else {
					for(int i=0;i<len;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j*len<=n;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
int que;
void pre(){
	for(int j=1;j<=que;j++){
		for(int i=1;i<=len&&(j-1)*len+i<=n;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j*len<=n;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	que=(n-1)/len+1;
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j<=que;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else if((j*len>=l&&(j-1)*len<=l)||((j-1)*len<=r&&j*len>=r)||((j-1)*len>=l&&j*len<=r)){
					for(int i=0;i<len&&(j-1)*len+i<=n;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j<=que;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				sort(res.begin(),res.end());
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<pair<ll,ll>>v[1000];
ll laze[1000];
ll a[1000000];
vector<ll>res;
int len,n;
int que;
void pre(){
	for(int j=1;j<=que;j++){
		for(int i=1;i<=len&&(j-1)*len+i<=n;i++){
			v[j].pb(mp(a[(j-1)*len+i],1ll*(j-1)*len+i));
		}
		laze[j]=0;
	}
	for(int j=1;j<=que;j++){
		sort(v[j].begin(),v[j].end());
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int q;
	cin >> n >> q;
	rep(i,1,n+1) cin >> a[i];
	len=sqrt(n);
	que=(n-1)/len+1;
	pre();
	while(q--){
		int type;
		cin >> type;
		if(type==1){
			int l,r;
			ll val;
			cin >> l >> r >> val;
			for(int j=1;j<=que;j++){
				if((j-1)*len>=l&&j*len<=r) laze[j]+=val;
				else if((j*len>=l&&(j-1)*len<=l)||((j-1)*len<=r&&j*len>=r)||((j-1)*len>=l&&j*len<=r)){
					for(int i=0;i<len&&(j-1)*len+i<=n;i++){
						if(v[j][i].se>=l&&v[j][i].se<=r) v[j][i].fi+=val;
					}
					sort(v[j].begin(),v[j].end());
				}
			}
		}
		else{
			ll val;
			cin >> val;
			for(int j=1;j<=que;j++){
				auto t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j],1ll*0));
				if(t!=v[j].end()&&(*t).fi+laze[j]==val){
					res.pb((*t).se);
				}
				t=lower_bound(v[j].begin(),v[j].end(),mp(val-laze[j]+1,1ll*0));
				if(t!=v[j].begin()){
					t--;
					if((*t).fi==val-laze[j]) res.pb((*t).se);
				}
			}
			if(res.size()==0){
				cout<<"-1"<<endl;
			}
			else{
				sort(res.begin(),res.end());
				cout<<res[res.size()-1]-res[0]<<endl;
				res.clear();
			}
		}
	}
	return 0;
}
/*
8 1
1 1 1 2 1 3 1 1
2 1*/


#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 500005
#define MAXS 805
#define NIL (MAXN-1)
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	lint a;
	int b;
	bool operator < (ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int ren, l, r;
lint arr[MAXN], lz[MAXS];
vector<ii> buc[MAXS];

void init() {
	ren = sqrt(N);
	for (int i = 0; i < N; i++) {
		buc[i/ren].push_back({arr[i], i});
		if (i%ren == ren-1) sort(buc[i/ren].begin(), buc[i/ren].end());
	}
	sort(buc[(N-1)/ren].begin(), buc[(N-1)/ren].end());
}

void subupdate(int l, int r, int v) {
	int b = l/ren;
	vector<vector<ii>::iterator> temp;
	for (int i = l; i <= r; i++) {
		auto pos = lower_bound(buc[b].begin(), buc[b].end(), (ii){arr[i], i});
		arr[i] += v;
		temp.push_back(pos);
	}
	for (auto i: temp) i->a = arr[i->b];
	sort(buc[b].begin(), buc[b].end());
}

void update(int l, int r, int v) {
	int bl = l/ren, br = r/ren;
	if (bl == br) subupdate(l, r, v);
	else {
		subupdate(l, bl*ren+ren-1, v);
		for (int i = bl+1; i < br; i++) lz[i] += v;
		subupdate(br*ren, r, v);
	}
}

void subquery(int ll, int rr, int v) {
	int b = ll/ren;
	for (int i = ll; i <= rr; i++) {
		if (arr[i]+lz[b] == v) {
			l = min(l, i);
			r = max(r, i);
		}
	}
}

void query(int v) {
	l = INF, r = -INF;
	int bl = 0/ren, br = (N-1)/ren;
	if (bl == br) subquery(0, N-1, v);
	else {
		subquery(0, bl*ren+ren-1, v);
		for (int i = bl+1; i < br; i++) {
			auto lb = lower_bound(buc[i].begin(), buc[i].end(), (ii){v-lz[i], 0});
			auto ub = upper_bound(buc[i].begin(), buc[i].end(), (ii){v-lz[i], INF});
			if (lb == buc[i].end()) continue;
			l = min(l, lb->b);
			r = max(r, prev(ub)->b);
		}
		subquery(br*ren, N-1, v);
	}
	if (l == INF) puts("-1");
	else printf("%d\n", r-l);
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif

	scanf("%d%d", &N, &Q);
	for (int i = 0; i < N; i++) scanf("%lld", &arr[i]);
	init();
	for (int i = 0; i < Q; i++) {
		int op;
		scanf("%d", &op);
		if (op == 1) {
			scanf("%d%d%d", &x, &y, &z);
			update(x-1, y-1, z);
		}
		else {
			scanf("%d", &x);
			query(x);
		}
	}

	return 0;
}


#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 500005
#define MAXS 805
#define NIL (MAXN-1)
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	lint a, b;
	bool operator < (ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int ren;
lint arr[MAXN], lz[MAXS];
multiset<ii> buc[MAXS];

void init() {
	ren = sqrt(N);
	for (int i = 0; i < N; i++) {
		buc[i/ren].insert({arr[i], i});
	}
}

void update(int l, int r, int v) {
	int i = l;
	while (i <= r && i%ren != 0) {
		buc[i/ren].erase({arr[i], i});
		arr[i] += v;
		buc[i/ren].insert({arr[i], i});
		i++;
	}
	while (i+ren-1 <= r) {
		lz[i/ren] += v;
		i++;
	}
	while (i <= r) {
		buc[i/ren].erase({arr[i], i});
		arr[i] += v;
		buc[i/ren].insert({arr[i], i});
		i++;
	}
}

void query(int v) {
	lint l = INF, r = -INF;
	lint i = 0;
	while (i < N && i%ren != 0) {
		if (arr[i]+lz[i/ren] == v) {
			l = min(l, i);
			r = max(r, i);
		}
		i++;
	}
	while (i+ren-1 < N) {
		auto lb = buc[i/ren].lower_bound({v-lz[i/ren], 0});
		auto ub = prev(buc[i/ren].upper_bound({v-lz[i/ren], 0}));
		if (lb->a == v-lz[i/ren]) {
			l = min(l, lb->b);
			r = max(r, lb->b);
		}
		if (ub->a == v-lz[i/ren]) {
			l = min(l, lb->b);
			r = max(r, lb->b);
		}
		i++;
	}
	while (i < N) {
		if (arr[i]+lz[i/ren] == v) {
			l = min(l, i);
			r = max(r, i);
		}
		i++;
	}
	if (l == INF) puts("-1");
	else printf("%lld\n", r-l);
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif

	scanf("%d%d", &N, &Q);
	for (int i = 0; i < N; i++) scanf("%lld", &arr[i]);
	init();
	for (int i = 0; i < Q; i++) {
		int op;
		scanf("%d", &op);
		if (op == 1) {
			scanf("%d%d%d", &x, &y, &z);
			update(x-1, y-1, z);
		}
		else {
			scanf("%d", &x);
			query(x);
		}
	}

	return 0;
}