#include <bits/stdc++.h>
using namespace std;
template <class T = int>
using V = std::vector<T>;
template <class T = int>
using VV = std::vector<std::vector<T>>;
template <class T = int>
using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
using ll = long long;
using ld = long double;
using int128 = __int128_t;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
  for (T &i : v) is >> i;
  return is;
}
std::istream &operator>>(std::istream &is, __int128_t &a) {
  std::string s;
  is >> s;
  __int128_t ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
  a = ret * (s[0] == '-' ? -1 : 1);
  return is;
}
namespace scanner {
void scan(int &a) { std::cin >> a; }
void scan(long long &a) { std::cin >> a; }
void scan(std::string &a) { std::cin >> a; }
void scan(char &a) { std::cin >> a; }
void scan(char a[]) { std::scanf("%s", a); }
void scan(double &a) { std::cin >> a; }
void scan(long double &a) { std::cin >> a; }
template <class T, class U>
void scan(std::pair<T, U> &p) {
  std::cin >> p;
}
template <class T>
void scan(std::vector<T> &a) {
  std::cin >> a;
}
void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &...tail) {
  scan(head);
  INPUT(tail...);
}
}  // namespace scanner
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &a) {
  for (int i = 0; i < int(a.size()); ++i) {
    if (i) os << " ";
    os << a[i];
  }
  return os;
}
std::ostream &operator<<(std::ostream &dest, __int128_t &value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
template <class T>
void print(const T a) {
  std::cout << a << '\n';
}
template <class Head, class... Tail>
void print(Head H, Tail... T) {
  std::cout << H << ' ';
  print(T...);
}
template <class T>
void printel(const T a) {
  std::cout << a << '\n';
}
template <class T>
void printel(const std::vector<T> &a) {
  for (const auto &v : a) std::cout << v << '\n';
}
template <class Head, class... Tail>
void printel(Head H, Tail... T) {
  std::cout << H << '\n';
  printel(T...);
}
void Yes(const bool b = true) { std::cout << (b ? "Yes\n" : "No\n"); }
void No() { std::cout << "No\n"; }
void YES(const bool b = true) { std::cout << (b ? "YES\n" : "NO\n"); }
void NO() { std::cout << "No\n"; }
void err(const bool b = true) {
  if (b) {
    std::cout << "-1\n", exit(0);
  }
}
namespace debugger {
template <class T>
void view(const std::vector<T> &a) {
  std::cerr << "{ ";
  for (const auto &v : a) {
    std::cerr << v << ", ";
  }
  std::cerr << "\b\b }";
}
template <class T>
void view(const std::vector<std::vector<T>> &a) {
  std::cerr << "{\n";
  for (const auto &v : a) {
    std::cerr << "\t";
    view(v);
    std::cerr << "\n";
  }
  std::cerr << "}";
}
template <class T, class U>
void view(const std::vector<std::pair<T, U>> &a) {
  std::cerr << "{\n";
  for (const auto &p : a)
    std::cerr << "\t(" << p.first << ", " << p.second << ")\n";
  std::cerr << "}";
}
template <class T, class U>
void view(const std::map<T, U> &m) {
  std::cerr << "{\n";
  for (const auto &p : m)
    std::cerr << "\t[" << p.first << "] : " << p.second << "\n";
  std::cerr << "}";
}
template <class T, class U>
void view(const std::pair<T, U> &p) {
  std::cerr << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void view(const std::set<T> &s) {
  std::cerr << "{ ";
  for (auto &v : s) {
    view(v);
    std::cerr << ", ";
  }
  std::cerr << "\b\b }";
}
template <class T>
void view(const T &e) {
  std::cerr << e;
}
}  // namespace debugger
template <class T>
int lb(const std::vector<T> &a, const T x) {
  return std::distance((a).begin(),
                       std::lower_bound((a).begin(), (a).end(), (x)));
}
template <class T>
int ub(const std::vector<T> &a, const T x) {
  return std::distance((a).begin(),
                       std::upper_bound((a).begin(), (a).end(), (x)));
}
template <class T>
void UNIQUE(std::vector<T> &a) {
  std::sort(a.begin(), a.end());
  a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<T> press(std::vector<T> &a) {
  auto res = a;
  UNIQUE(res);
  for (auto &v : a) v = lb(res, v);
  return res;
}
template <class T>
void ADD(std::vector<T> &a, const T x) {
  for (auto &v : a) v += x;
}
template <class T>
void SUB(std::vector<T> &a, const T x = 1) {
  for (auto &v : a) v -= x;
}
template <class T>
void MUL(std::vector<T> &a, const T x) {
  for (auto &v : a) v *= x;
}
template <class T>
void DIV(std::vector<T> &a, const T x) {
  for (auto &v : a) v /= x;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  return a > b ? a = b, true : false;
}
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  return a < b ? a = b, true : false;
}
template <class T>
T divup(T x, T y) {
  return (x + y - 1) / y;
}
template <class T>
T POW(T a, long long n) {
  T ret = 1;
  while (n) {
    if (n & 1) ret *= a;
    a *= a;
    n >>= 1;
  }
  return ret;
}
long long POW(long long a, long long n, const int mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) (ret *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return ret;
}
struct fast_io {
  fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
  }
} fast_io_;
using R = long double;
constexpr R EPS = 1E-11;
int sgn(const R &r) { return (r > EPS) - (r < -EPS); }
int sgn(const R &a, const R &b) { return sgn(a - b); }
long long x10(const string &s, size_t n) {
  if (s.front() == '-') return -x10(s.substr(1), n);
  auto pos = s.find('.');
  if (pos == string::npos) return stoll(s + string(n, '0'));
  return stoll(s.substr(0, pos) + s.substr(pos + 1) +
               string(n + pos + 1 - s.size(), '0'));
}
long long ceildiv(long long a, long long b) {
  if (b < 0) a = -a, b = -b;
  if (a >= 0)
    return (a + b - 1) / b;
  else
    return a / b;
}
long long floordiv(long long a, long long b) {
  if (b < 0) a = -a, b = -b;
  if (a >= 0)
    return a / b;
  else
    return (a - b + 1) / b;
}
long long floorsqrt(long long x) {
  assert(x >= 0);
  long long ok = 0;
  long long ng = 1;
  while (ng * ng <= x) ng <<= 1;
  while (ng - ok > 1) {
    long long mid = (ng + ok) >> 1;
    if (mid * mid <= x)
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
inline int topbit(unsigned long long x) {
  return x ? 63 - __builtin_clzll(x) : -1;
}
inline int popcount(unsigned long long x) { return __builtin_popcountll(x); }
inline int parity(unsigned long long x) { return __builtin_parity(x); }
const int inf = 1e9;
const ll INF = 1e18;
struct SegmentTree {
 private:
  int n;
  vector<ll> node;

 public:
  SegmentTree(vector<ll> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, INF);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
  }
  void update(int x, ll val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2 * x + 1], node[2 * x + 2]);
    }
  }
  ll getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return node[k];
    ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};
template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S),
          F (*composition)(F, F), F (*id)()>
struct lazy_segtree {
 public:
  lazy_segtree() : lazy_segtree(0) {}
  lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
  lazy_segtree(const std::vector<S> &v) : _n(int(v.size())) {
    int x = 0;
    while ((1U << x) < (unsigned int)(_n)) x++;
    log = x;
    size = 1 << log;
    d = std::vector<S>(2 * size, e());
    lz = std::vector<F>(size, id());
    for (int i = 0; i < _n; i++) d[size + i] = v[i];
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }
  void set(int p, S x) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = x;
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  S get(int p) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    return d[p];
  }
  S prod(int l, int r) {
    if (l == r) return e();
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push(r >> i);
    }
    S sml = e(), smr = e();
    while (l < r) {
      if (l & 1) sml = op(sml, d[l++]);
      if (r & 1) smr = op(d[--r], smr);
      l >>= 1;
      r >>= 1;
    }
    return op(sml, smr);
  }
  S all_prod() { return d[1]; }
  void apply(int p, F f) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = mapping(f, d[p]);
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  void apply(int l, int r, F f) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return;
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }
    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1) all_apply(l++, f);
        if (r & 1) all_apply(--r, f);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }
    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l) update(l >> i);
      if (((r >> i) << i) != r) update((r - 1) >> i);
    }
  }
  template <bool (*g)(S)>
  int max_right(int l) {
    return max_right(l, [](S x) { return g(x); });
  }
  template <class G>
  int max_right(int l, G g) {
    assert(0 <= l && l <= _n);
    assert(g(e()));
    if (l == _n) return _n;
    l += size;
    for (int i = log; i >= 1; i--) push(l >> i);
    S sm = e();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!g(op(sm, d[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (g(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }
  template <bool (*g)(S)>
  int min_left(int r) {
    return min_left(r, [](S x) { return g(x); });
  }
  template <class G>
  int min_left(int r, G g) {
    assert(0 <= r && r <= _n);
    assert(g(e()));
    if (r == 0) return 0;
    r += size;
    for (int i = log; i >= 1; i--) push((r - 1) >> i);
    S sm = e();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!g(op(d[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (g(op(d[r], sm))) {
            sm = op(d[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = op(d[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

 private:
  int _n, size, log;
  std::vector<S> d;
  std::vector<F> lz;
  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
  void all_apply(int k, F f) {
    d[k] = mapping(f, d[k]);
    if (k < size) lz[k] = composition(f, lz[k]);
  }
  void push(int k) {
    all_apply(2 * k, lz[k]);
    all_apply(2 * k + 1, lz[k]);
    lz[k] = id();
  }
};
using S = long long;
using F = long long;
const F ID = 8e18;
S op(S a, S b) { return std::min(a, b); }
S e() { return INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }
void main_() {
  long long N, K;
  scanner::INPUT(N, K);
  std::vector<ll> b(N);
  scanner::INPUT(b);
  long long Q;
  scanner::INPUT(Q);
  VV<ll> a(Q);
  set<ll> s;
  for (int i = 0; i < (Q); ++i) {
    V<ll> tmp;
    ll t, l, r, x;
    cin >> t >> l >> r;
    l--;
    tmp.push_back(t);
    tmp.push_back(l);
    tmp.push_back(r);
    s.insert(l);
    s.insert(r);
    if (t == 1) {
      cin >> x;
      tmp.push_back(x);
    }
    a[i] = tmp;
  }
  s.insert(0);
  s.insert(N * K);
  ll idx = 0;
  V<ll> nums;
  map<ll, ll> f;
  for (auto v : s) {
    f[v] = idx;
    nums.push_back(v);
    idx++;
  }
  V<ll> vec(idx - 1, INF - 100);
  V<ll> c(N);
  SegmentTree seg = SegmentTree(c);
  for (int i = 0; i < (N); ++i) seg.update(i, b[i]);
  for (int i = 0; i < (idx - 1); ++i) {
    ll l = nums[i], r = nums[i + 1];
    if (l % N > r % N)
      vec[i] = min(vec[i], min(seg.getmin(l % N, N), seg.getmin(0, r % N)));
    else
      vec[i] = min(vec[i], seg.getmin(l % N, r % N));
    if (r - l >= N) vec[i] = min(vec[i], seg.getmin(0LL, N));
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg2(vec);
  for (int i = 0; i < (Q); ++i) {
    if (a[i][0] == 1) {
      seg2.apply(f[a[i][1]], f[a[i][2]], a[i][3]);
    } else {
      cout << seg2.prod(f[a[i][1]], f[a[i][2]]) << endl;
    }
  }
}
int main() {
  int t = 1;
  while (t--) main_();
  return 0;
}

### Prompt

In Cpp, your task is to solve 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;
template <class T = int>
using V = std::vector<T>;
template <class T = int>
using VV = std::vector<std::vector<T>>;
template <class T = int>
using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
using ll = long long;
using ld = long double;
using int128 = __int128_t;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
  for (T &i : v) is >> i;
  return is;
}
std::istream &operator>>(std::istream &is, __int128_t &a) {
  std::string s;
  is >> s;
  __int128_t ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
  a = ret * (s[0] == '-' ? -1 : 1);
  return is;
}
namespace scanner {
void scan(int &a) { std::cin >> a; }
void scan(long long &a) { std::cin >> a; }
void scan(std::string &a) { std::cin >> a; }
void scan(char &a) { std::cin >> a; }
void scan(char a[]) { std::scanf("%s", a); }
void scan(double &a) { std::cin >> a; }
void scan(long double &a) { std::cin >> a; }
template <class T, class U>
void scan(std::pair<T, U> &p) {
  std::cin >> p;
}
template <class T>
void scan(std::vector<T> &a) {
  std::cin >> a;
}
void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &...tail) {
  scan(head);
  INPUT(tail...);
}
}  // namespace scanner
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &a) {
  for (int i = 0; i < int(a.size()); ++i) {
    if (i) os << " ";
    os << a[i];
  }
  return os;
}
std::ostream &operator<<(std::ostream &dest, __int128_t &value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
template <class T>
void print(const T a) {
  std::cout << a << '\n';
}
template <class Head, class... Tail>
void print(Head H, Tail... T) {
  std::cout << H << ' ';
  print(T...);
}
template <class T>
void printel(const T a) {
  std::cout << a << '\n';
}
template <class T>
void printel(const std::vector<T> &a) {
  for (const auto &v : a) std::cout << v << '\n';
}
template <class Head, class... Tail>
void printel(Head H, Tail... T) {
  std::cout << H << '\n';
  printel(T...);
}
void Yes(const bool b = true) { std::cout << (b ? "Yes\n" : "No\n"); }
void No() { std::cout << "No\n"; }
void YES(const bool b = true) { std::cout << (b ? "YES\n" : "NO\n"); }
void NO() { std::cout << "No\n"; }
void err(const bool b = true) {
  if (b) {
    std::cout << "-1\n", exit(0);
  }
}
namespace debugger {
template <class T>
void view(const std::vector<T> &a) {
  std::cerr << "{ ";
  for (const auto &v : a) {
    std::cerr << v << ", ";
  }
  std::cerr << "\b\b }";
}
template <class T>
void view(const std::vector<std::vector<T>> &a) {
  std::cerr << "{\n";
  for (const auto &v : a) {
    std::cerr << "\t";
    view(v);
    std::cerr << "\n";
  }
  std::cerr << "}";
}
template <class T, class U>
void view(const std::vector<std::pair<T, U>> &a) {
  std::cerr << "{\n";
  for (const auto &p : a)
    std::cerr << "\t(" << p.first << ", " << p.second << ")\n";
  std::cerr << "}";
}
template <class T, class U>
void view(const std::map<T, U> &m) {
  std::cerr << "{\n";
  for (const auto &p : m)
    std::cerr << "\t[" << p.first << "] : " << p.second << "\n";
  std::cerr << "}";
}
template <class T, class U>
void view(const std::pair<T, U> &p) {
  std::cerr << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void view(const std::set<T> &s) {
  std::cerr << "{ ";
  for (auto &v : s) {
    view(v);
    std::cerr << ", ";
  }
  std::cerr << "\b\b }";
}
template <class T>
void view(const T &e) {
  std::cerr << e;
}
}  // namespace debugger
template <class T>
int lb(const std::vector<T> &a, const T x) {
  return std::distance((a).begin(),
                       std::lower_bound((a).begin(), (a).end(), (x)));
}
template <class T>
int ub(const std::vector<T> &a, const T x) {
  return std::distance((a).begin(),
                       std::upper_bound((a).begin(), (a).end(), (x)));
}
template <class T>
void UNIQUE(std::vector<T> &a) {
  std::sort(a.begin(), a.end());
  a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<T> press(std::vector<T> &a) {
  auto res = a;
  UNIQUE(res);
  for (auto &v : a) v = lb(res, v);
  return res;
}
template <class T>
void ADD(std::vector<T> &a, const T x) {
  for (auto &v : a) v += x;
}
template <class T>
void SUB(std::vector<T> &a, const T x = 1) {
  for (auto &v : a) v -= x;
}
template <class T>
void MUL(std::vector<T> &a, const T x) {
  for (auto &v : a) v *= x;
}
template <class T>
void DIV(std::vector<T> &a, const T x) {
  for (auto &v : a) v /= x;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  return a > b ? a = b, true : false;
}
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  return a < b ? a = b, true : false;
}
template <class T>
T divup(T x, T y) {
  return (x + y - 1) / y;
}
template <class T>
T POW(T a, long long n) {
  T ret = 1;
  while (n) {
    if (n & 1) ret *= a;
    a *= a;
    n >>= 1;
  }
  return ret;
}
long long POW(long long a, long long n, const int mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) (ret *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return ret;
}
struct fast_io {
  fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
  }
} fast_io_;
using R = long double;
constexpr R EPS = 1E-11;
int sgn(const R &r) { return (r > EPS) - (r < -EPS); }
int sgn(const R &a, const R &b) { return sgn(a - b); }
long long x10(const string &s, size_t n) {
  if (s.front() == '-') return -x10(s.substr(1), n);
  auto pos = s.find('.');
  if (pos == string::npos) return stoll(s + string(n, '0'));
  return stoll(s.substr(0, pos) + s.substr(pos + 1) +
               string(n + pos + 1 - s.size(), '0'));
}
long long ceildiv(long long a, long long b) {
  if (b < 0) a = -a, b = -b;
  if (a >= 0)
    return (a + b - 1) / b;
  else
    return a / b;
}
long long floordiv(long long a, long long b) {
  if (b < 0) a = -a, b = -b;
  if (a >= 0)
    return a / b;
  else
    return (a - b + 1) / b;
}
long long floorsqrt(long long x) {
  assert(x >= 0);
  long long ok = 0;
  long long ng = 1;
  while (ng * ng <= x) ng <<= 1;
  while (ng - ok > 1) {
    long long mid = (ng + ok) >> 1;
    if (mid * mid <= x)
      ok = mid;
    else
      ng = mid;
  }
  return ok;
}
inline int topbit(unsigned long long x) {
  return x ? 63 - __builtin_clzll(x) : -1;
}
inline int popcount(unsigned long long x) { return __builtin_popcountll(x); }
inline int parity(unsigned long long x) { return __builtin_parity(x); }
const int inf = 1e9;
const ll INF = 1e18;
struct SegmentTree {
 private:
  int n;
  vector<ll> node;

 public:
  SegmentTree(vector<ll> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, INF);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
  }
  void update(int x, ll val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2 * x + 1], node[2 * x + 2]);
    }
  }
  ll getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return node[k];
    ll vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};
template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S),
          F (*composition)(F, F), F (*id)()>
struct lazy_segtree {
 public:
  lazy_segtree() : lazy_segtree(0) {}
  lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
  lazy_segtree(const std::vector<S> &v) : _n(int(v.size())) {
    int x = 0;
    while ((1U << x) < (unsigned int)(_n)) x++;
    log = x;
    size = 1 << log;
    d = std::vector<S>(2 * size, e());
    lz = std::vector<F>(size, id());
    for (int i = 0; i < _n; i++) d[size + i] = v[i];
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }
  void set(int p, S x) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = x;
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  S get(int p) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    return d[p];
  }
  S prod(int l, int r) {
    if (l == r) return e();
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push(r >> i);
    }
    S sml = e(), smr = e();
    while (l < r) {
      if (l & 1) sml = op(sml, d[l++]);
      if (r & 1) smr = op(d[--r], smr);
      l >>= 1;
      r >>= 1;
    }
    return op(sml, smr);
  }
  S all_prod() { return d[1]; }
  void apply(int p, F f) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = mapping(f, d[p]);
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  void apply(int l, int r, F f) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return;
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }
    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1) all_apply(l++, f);
        if (r & 1) all_apply(--r, f);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }
    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l) update(l >> i);
      if (((r >> i) << i) != r) update((r - 1) >> i);
    }
  }
  template <bool (*g)(S)>
  int max_right(int l) {
    return max_right(l, [](S x) { return g(x); });
  }
  template <class G>
  int max_right(int l, G g) {
    assert(0 <= l && l <= _n);
    assert(g(e()));
    if (l == _n) return _n;
    l += size;
    for (int i = log; i >= 1; i--) push(l >> i);
    S sm = e();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!g(op(sm, d[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (g(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }
  template <bool (*g)(S)>
  int min_left(int r) {
    return min_left(r, [](S x) { return g(x); });
  }
  template <class G>
  int min_left(int r, G g) {
    assert(0 <= r && r <= _n);
    assert(g(e()));
    if (r == 0) return 0;
    r += size;
    for (int i = log; i >= 1; i--) push((r - 1) >> i);
    S sm = e();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!g(op(d[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (g(op(d[r], sm))) {
            sm = op(d[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = op(d[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

 private:
  int _n, size, log;
  std::vector<S> d;
  std::vector<F> lz;
  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
  void all_apply(int k, F f) {
    d[k] = mapping(f, d[k]);
    if (k < size) lz[k] = composition(f, lz[k]);
  }
  void push(int k) {
    all_apply(2 * k, lz[k]);
    all_apply(2 * k + 1, lz[k]);
    lz[k] = id();
  }
};
using S = long long;
using F = long long;
const F ID = 8e18;
S op(S a, S b) { return std::min(a, b); }
S e() { return INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }
void main_() {
  long long N, K;
  scanner::INPUT(N, K);
  std::vector<ll> b(N);
  scanner::INPUT(b);
  long long Q;
  scanner::INPUT(Q);
  VV<ll> a(Q);
  set<ll> s;
  for (int i = 0; i < (Q); ++i) {
    V<ll> tmp;
    ll t, l, r, x;
    cin >> t >> l >> r;
    l--;
    tmp.push_back(t);
    tmp.push_back(l);
    tmp.push_back(r);
    s.insert(l);
    s.insert(r);
    if (t == 1) {
      cin >> x;
      tmp.push_back(x);
    }
    a[i] = tmp;
  }
  s.insert(0);
  s.insert(N * K);
  ll idx = 0;
  V<ll> nums;
  map<ll, ll> f;
  for (auto v : s) {
    f[v] = idx;
    nums.push_back(v);
    idx++;
  }
  V<ll> vec(idx - 1, INF - 100);
  V<ll> c(N);
  SegmentTree seg = SegmentTree(c);
  for (int i = 0; i < (N); ++i) seg.update(i, b[i]);
  for (int i = 0; i < (idx - 1); ++i) {
    ll l = nums[i], r = nums[i + 1];
    if (l % N > r % N)
      vec[i] = min(vec[i], min(seg.getmin(l % N, N), seg.getmin(0, r % N)));
    else
      vec[i] = min(vec[i], seg.getmin(l % N, r % N));
    if (r - l >= N) vec[i] = min(vec[i], seg.getmin(0LL, N));
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg2(vec);
  for (int i = 0; i < (Q); ++i) {
    if (a[i][0] == 1) {
      seg2.apply(f[a[i][1]], f[a[i][2]], a[i][3]);
    } else {
      cout << seg2.prod(f[a[i][1]], f[a[i][2]]) << endl;
    }
  }
}
int main() {
  int t = 1;
  while (t--) main_();
  return 0;
}

```