#include using namespace std; #include using ll=long long; struct S{ ll sqr,sum,len; }; int main(){ int N;cin>>N; vector init(N); for(int i=0;i>a; init[i]={a*a,a,1}; } atcoder::lazy_segtree seg(init); int Q;cin>>Q; while(Q--){ ll com,l,r,x; cin>>com>>l>>r; l--; if(com==1){ cin>>x; seg.apply(l,r,x); } else if(com==2){ cout<