#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V  = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


struct Monoid {
  using T = struct { double min, max, sum; };
  static T op(const T& lhs, const T& rhs) { return {min(lhs.min, rhs.min), max(lhs.max, rhs.max), lhs.sum + rhs.sum}; }
  static constexpr T e() { return {numeric_limits<double>::max(), numeric_limits<double>::min(), 0}; }
};

template<class Monoid> struct MonoidAct {
  using T = struct { double a, b; };
  static void ap(const T& f, typename Monoid::T& a, int len) {
    tie(a.min, a.max) = minmax(f.a * a.min + f.b, f.a * a.max + f.b);
    a.sum = f.a * a.sum + f.b * len;
  }
  static void cp(const T& f, T& g) { g.a *= f.a, g.b = f.a * g.b + f.b; }
  static constexpr T id() { return {1, 0}; }
};

template<class Monoid, class MonoidAct> struct SegmentTree {
  using Tv = typename Monoid::T;
  using Ta = typename MonoidAct::T;

  int n;
  V<Tv> val;
  V<Ta> act;
  V<> len;

  SegmentTree(int n) : n(n), val(2 * n, Monoid::e()), act(n, MonoidAct::id()), len(2 * n, 1) {
    for (int i = n - 1; i > 0; --i) len[i] = len[2 * i] + len[2 * i + 1];
  }

  SegmentTree(auto first, auto last) : n(distance(first, last)), val(2 * n, Monoid::e()), act(n, MonoidAct::id()), len(2 * n, 1) {
    copy(first, last, next(begin(val), n));
    build();
    for (int i = n - 1; i > 0; --i) len[i] = len[2 * i] + len[2 * i + 1];
  }

  void _ap(const Ta& f, int i) {
    MonoidAct::ap(f, val[i], len[i]);
    if (i < n) MonoidAct::cp(f, act[i]);
  }

  void build() {
    for (int i = n - 1; i > 0; --i) val[i] = Monoid::op(val[2 * i], val[2 * i + 1]);
  }

  Tv get(int l, int r) {
    _push(l, r);
    Tv resl = Monoid::e(), resr = Monoid::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = Monoid::op(resl, val[l++]);
      if (r & 1) resr = Monoid::op(val[--r], resr);
    }
    return Monoid::op(resl, resr);
  }

  void push() {
    for (int i = 1; i < n; ++i) _push(i);
  }

  void _push(int i) {
    _ap(act[i], 2 * i);
    _ap(act[i], 2 * i + 1);
    act[i] = MonoidAct::id();
  }

  void _push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) _push(al);
      if (ar != al) _push(ar);
    }
  }

  void set(int l, int r, const Ta& f) {
    _push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(f, i++);
      if (j & 1) _ap(f, --j);
    }
    for (l += n; !(l & 1); l >>= 1);
    while ((l >>= 1) > 0) val[l] = Monoid::op(val[2 * l], val[2 * l + 1]);
    for (r += n; !(r & 1); r >>= 1);
    while ((r >>= 1) > 0) val[r] = Monoid::op(val[2 * r], val[2 * r + 1]);
  }
};

struct RMQ {
  using T = int;
  static T op(const T& lhs, const T& rhs) { return min(lhs, rhs); }
  static constexpr T e() { return numeric_limits<T>::max(); }
};

template<class RMQ> struct RUQ {
  using T = int;
  static void ap(const T& f, typename RMQ::T& a, int len) { a = f == -1 ? a : f; }
  static void cp(const T& f, T& g) { g = f == -1 ? g : f; }
  static constexpr T id() { return -1; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  SegmentTree< RMQ, RUQ<RMQ> > st(n);
  for (int iq = 0; iq < q; ++iq) {
    int c; cin >> c;
    if (!c) {
      int l, r, x; cin >> l >> r >> x, ++r;
      st.set(l, r, x);
    } else {
      int l, r; cin >> l >> r, ++r;
      cout << st.get(l, r) << '\n';
    }
  }
}


Measured memory_bytes: 5004