#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

signed main(){
    ll n,q,l,r;
    cin>>n>>q>>l>>r;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll p[q],x[q],s[q],t[q];
    for(int i=0;i<q;i++){
        cin>>p[i]>>x[i]>>s[i]>>t[i];
    }
    sort(a,a+n);
    ll low = 0,up = n;
    while(up-low>0){
        ll mid = (low+up)/2;
        ll now = a[mid];
        for(int i=0;i<q;i++){
            if(p[i]==1){
                if(x[i]>now) continue;
                now = t[i] * (now+s[i]);
            }
            else {
                if(x[i]<now) continue;
                now = (now - s[i])/t[i];
            }
        }
        if(now<l){
            low = mid+1;
        }
        else up = mid;
    }
    ll L=low;
    low = 0, up = n;
    while(up-low>0){
        ll mid = (low+up)/2;
        ll now = a[mid];
        for(int i=0;i<q;i++){
            if(p[i]==1){
                if(x[i]>now) continue;
                now = t[i] * (now+s[i]);
            }
            else {
                if(x[i]<now) continue;
                now = (now - s[i])/t[i];
            }
        }
        if(now<=r){
            low = mid+1;
        }
        else up = mid;
    }
    ll R = low;
    //cout << L << " " << R << endl;
    ll ans = max(0LL,R-L);
    cout << ans << endl;
}
