#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long,long long>
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define sz(x) (int)(x).size()
#define rsz resize
#define ass assign
#define F(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define each(a,x) for(auto a:x)
#define FOR(i,a) for(int i=0;i<(a);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define eb emplace_back
#define ft front()
#define V vector
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
const int maxn=400005;
const ll inf=1e18;
struct ST{
#define lc (n<<1)
#define rc (n<<1|1)
ll t[4*maxn],lazy[4*maxn];
ST(){
fill(t,t+4*maxn,0);
fill(lazy,lazy+4*maxn,0);
}
inline void push(int n,int b,int e){
if(!lazy[n])return;
t[n]+=lazy[n];
if(b!=e){
lazy[lc]+=lazy[n];
lazy[rc]+=lazy[n];
}
lazy[n]=0;
}
inline void pull(int n){
t[n]=max(t[lc],t[rc]);
}
void upd(int n,int b,int e,int i,int j,ll v){
push(n,b,e);
if(j<b || e<i)return;
if(i<=b && e<=j){
lazy[n]+=v;
push(n,b,e);
return;
}
int mid=(b+e)>>1;
upd(lc,b,mid,i,j,v);
upd(rc,mid+1,e,i,j,v);
pull(n);
}
//to find a leave with val >= x and deactivate it
int find(int n,int b,int e,ll x){
push(n,b,e);
if(t[n]<x)return -1;
if(b==e){
t[n]=-inf;
return b;
}
int mid=(b+e)>>1;
int res=find(lc,b,mid,x);
if(!(~res))res=find(rc,mid+1,e,x);
pull(n);
return res;
}
} st;
void solve(){
ll h,w,n,x;
cin>>h>>w>>n>>x;
V<ll> u(n),d(n),l(n),r(n),c(n);
FOR(i,n)cin>>u[i]>>d[i]>>l[i]>>r[i]>>c[i];
if(x==1){
ll mnu=inf,mxd=-1,mnl=inf,mxr=-1;
FOR(i,n){
mnu=min(mnu,u[i]);
mxd=max(mxd,d[i]);
mnl=min(mnl,l[i]);
mxr=max(mxr,r[i]);
cout<<(mxd-mnu+1)*(mxr-mnl+1)<<'\n';
}
}
V<ll> coords;
FOR(i,n){
coords.pb(u[i]);
coords.pb(d[i]+1);
}
sort(coords.begin(),coords.end());
coords.erase(unique(coords.begin(),coords.end()),coords.end());
int m=sz(coords)-1;
ll mnu=inf,mxd=-1;
FOR(i,n){
int id1=lower_bound(coords.begin(),coords.end(),u[i])-coords.begin();
int id2=lower_bound(coords.begin(),coords.end(),d[i]+1)-coords.begin()-1;
st.upd(1,0,m-1,id1,id2,c[i]);
int found;
while((found=st.find(1,0,m-1,x))!=-1){
mnu=min(mnu,coords[found]);
mxd=max(mxd,coords[found+1]-1);
}
if(!(~mxd))cout<<"0\n";
else cout<<(mxd-mnu+1)<<'\n';
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
int tt=1;
//cin>>tt;
while(tt--)solve();
return 0;
}