#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const ll INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

int main(){
	ll n, q, l, r;
	cin >> n >> q >> l >> r;
	vector<ll> line(n);
	foreach(i, line)cin>>i;

	vector<vector<ll>> querys(q, vector<ll>(4));
	foreach(i, querys){
		foreach(j, i)cin >> j;
	}

	auto func = [&](ll num){
		foreach(i, querys){
			ll q = i[0], x = i[1], s = i[2], t = i[3];
			if(q==1){
				if(num>=x){
					num = (num + s) * t;
				}
			}else{
				if(num<=x){
					num = (num - s) / t;
				}
			}
		}
		int res = (l <= num)?1:0;
		res |= (num <= r)?2:0;
		return res;
	};

	sort(all(line));

	ll lo = 0, lh = n;
	while(lo < lh){
		ll mid = (lo+lh) >> 1;
		if(func(line[mid])&1){
			lh = mid;
		}else{
			lo = mid + 1;
		}
	}

	ll ro = 0, rh = n;
	while(ro < rh){
		ll mid = (ro+rh) >> 1;
		if(func(line[mid])&2){
			ro = mid + 1;
		}else{
			rh = mid;
		}
	}
	cout << ro - lo << endl;


	return 0;
}

