#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 5;
struct Node {
  int l, r;
  int val;
  int toPush;
  Node() : l(), r(), val(INF), toPush(-1) {}
  Node(int _l, int _r) : l(_l), r(_r), val(INF), toPush(-1) {}
};
const int N = 1 << 18;
Node tree[2 * N];
int a[N];
int n, k, m;
int q[N][4];
int xs[N];
int xsSz;
void build() {
  for (int i = 0; i < N; i++) tree[N + i] = Node(i, i + 1);
  for (int i = N - 1; i > 0; i--)
    tree[i] = Node(tree[2 * i].l, tree[2 * i + 1].r);
  return;
}
void push(int v) {
  if (v >= N) throw;
  if (tree[v].toPush == -1) return;
  for (int u = 2 * v; u < 2 * v + 2; u++) {
    tree[u].val = tree[v].toPush;
    tree[u].toPush = tree[v].toPush;
  }
  tree[v].toPush = -1;
  return;
}
void update(int v) {
  if (v >= N) throw;
  tree[v].val = min(tree[2 * v].val, tree[2 * v + 1].val);
  return;
}
void setOnSegm(int v, int l, int r, int x) {
  if (l <= tree[v].l && tree[v].r <= r) {
    tree[v].val = tree[v].toPush = x;
    return;
  }
  if (l >= tree[v].r || tree[v].l >= r) return;
  push(v);
  setOnSegm(2 * v, l, r, x);
  setOnSegm(2 * v + 1, l, r, x);
  update(v);
  return;
}
int getMin(int v, int l, int r) {
  if (l <= tree[v].l && tree[v].r <= r) return tree[v].val;
  if (l >= tree[v].r || tree[v].l >= r) return INF;
  push(v);
  return min(getMin(2 * v, l, r), getMin(2 * v + 1, l, r));
}
int getCyclicMin(int l, int r) {
  if (r - l >= n) return getMin(1, 0, n);
  l %= n;
  r %= n;
  if (l < r)
    return getMin(1, l, r);
  else
    return min(getMin(1, l, n), getMin(1, 0, r));
}
void read() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  build();
  for (int i = 0; i < n; i++) setOnSegm(1, i, i + 1, a[i]);
  scanf("%d", &m);
  xsSz = 0;
  xs[xsSz++] = 0;
  xs[xsSz++] = n * k;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &q[i][0], &q[i][1], &q[i][2]);
    if (q[i][0] == 1) scanf("%d", &q[i][3]);
    q[i][1]--;
    xs[xsSz++] = q[i][1];
    xs[xsSz++] = q[i][2];
  }
  sort(xs, xs + xsSz);
  xsSz = unique(xs, xs + xsSz) - xs;
  for (int i = 0; i < m; i++)
    for (int j = 1; j < 3; j++)
      q[i][j] = lower_bound(xs, xs + xsSz, q[i][j]) - xs;
  for (int i = 0; i < xsSz - 1; i++) a[i] = getCyclicMin(xs[i], xs[i + 1]);
  build();
  n = xsSz - 1;
  for (int i = 0; i < n; i++) setOnSegm(1, i, i + 1, a[i]);
  return;
}
int main() {
  read();
  for (int i = 0; i < m; i++) {
    if (q[i][0] == 1)
      setOnSegm(1, q[i][1], q[i][2], q[i][3]);
    else
      printf("%d\n", getMin(1, q[i][1], q[i][2]));
  }
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

You are given an array a consisting of positive integers and q queries to this array. There are two types of queries: 

  * 1 l r x — for each index i such that l ≤ i ≤ r set ai = x. 
  * 2 l r — find the minimum among such ai that l ≤ i ≤ r. 



We decided that this problem is too easy. So the array a is given in a compressed form: there is an array b consisting of n elements and a number k in the input, and before all queries a is equal to the concatenation of k arrays b (so the size of a is n·k).

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 104).

The second line contains n integers — elements of the array b (1 ≤ bi ≤ 109).

The third line contains one integer q (1 ≤ q ≤ 105).

Then q lines follow, each representing a query. Each query is given either as 1 l r x — set all elements in the segment from l till r (including borders) to x (1 ≤ l ≤ r ≤ n·k, 1 ≤ x ≤ 109) or as 2 l r — find the minimum among all elements in the segment from l till r (1 ≤ l ≤ r ≤ n·k).

Output

For each query of type 2 print the answer to this query — the minimum on the corresponding segment.

Examples

Input

3 1
1 2 3
3
2 1 3
1 1 2 4
2 1 3


Output

1
3


Input

3 2
1 2 3
5
2 4 4
1 4 4 5
2 4 4
1 1 6 1
2 6 6


Output

1
5
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 5;
struct Node {
  int l, r;
  int val;
  int toPush;
  Node() : l(), r(), val(INF), toPush(-1) {}
  Node(int _l, int _r) : l(_l), r(_r), val(INF), toPush(-1) {}
};
const int N = 1 << 18;
Node tree[2 * N];
int a[N];
int n, k, m;
int q[N][4];
int xs[N];
int xsSz;
void build() {
  for (int i = 0; i < N; i++) tree[N + i] = Node(i, i + 1);
  for (int i = N - 1; i > 0; i--)
    tree[i] = Node(tree[2 * i].l, tree[2 * i + 1].r);
  return;
}
void push(int v) {
  if (v >= N) throw;
  if (tree[v].toPush == -1) return;
  for (int u = 2 * v; u < 2 * v + 2; u++) {
    tree[u].val = tree[v].toPush;
    tree[u].toPush = tree[v].toPush;
  }
  tree[v].toPush = -1;
  return;
}
void update(int v) {
  if (v >= N) throw;
  tree[v].val = min(tree[2 * v].val, tree[2 * v + 1].val);
  return;
}
void setOnSegm(int v, int l, int r, int x) {
  if (l <= tree[v].l && tree[v].r <= r) {
    tree[v].val = tree[v].toPush = x;
    return;
  }
  if (l >= tree[v].r || tree[v].l >= r) return;
  push(v);
  setOnSegm(2 * v, l, r, x);
  setOnSegm(2 * v + 1, l, r, x);
  update(v);
  return;
}
int getMin(int v, int l, int r) {
  if (l <= tree[v].l && tree[v].r <= r) return tree[v].val;
  if (l >= tree[v].r || tree[v].l >= r) return INF;
  push(v);
  return min(getMin(2 * v, l, r), getMin(2 * v + 1, l, r));
}
int getCyclicMin(int l, int r) {
  if (r - l >= n) return getMin(1, 0, n);
  l %= n;
  r %= n;
  if (l < r)
    return getMin(1, l, r);
  else
    return min(getMin(1, l, n), getMin(1, 0, r));
}
void read() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  build();
  for (int i = 0; i < n; i++) setOnSegm(1, i, i + 1, a[i]);
  scanf("%d", &m);
  xsSz = 0;
  xs[xsSz++] = 0;
  xs[xsSz++] = n * k;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &q[i][0], &q[i][1], &q[i][2]);
    if (q[i][0] == 1) scanf("%d", &q[i][3]);
    q[i][1]--;
    xs[xsSz++] = q[i][1];
    xs[xsSz++] = q[i][2];
  }
  sort(xs, xs + xsSz);
  xsSz = unique(xs, xs + xsSz) - xs;
  for (int i = 0; i < m; i++)
    for (int j = 1; j < 3; j++)
      q[i][j] = lower_bound(xs, xs + xsSz, q[i][j]) - xs;
  for (int i = 0; i < xsSz - 1; i++) a[i] = getCyclicMin(xs[i], xs[i + 1]);
  build();
  n = xsSz - 1;
  for (int i = 0; i < n; i++) setOnSegm(1, i, i + 1, a[i]);
  return;
}
int main() {
  read();
  for (int i = 0; i < m; i++) {
    if (q[i][0] == 1)
      setOnSegm(1, q[i][1], q[i][2], q[i][3]);
    else
      printf("%d\n", getMin(1, q[i][1], q[i][2]));
  }
  return 0;
}

```