Types: N: int, M: int, r: int, q: int, records: List[Tuple[int, int, int, int]], queries: List[Tuple[int, int, int]]
Ranges: 1 ≤ N ≤ 1000, 1 ≤ M ≤ 10000, 2 ≤ r ≤ 1000, 1 ≤ q ≤ 50, 540 ≤ t ≤ 1260, 1 ≤ n ≤ N, 1 ≤ m ≤ M, 540 ≤ ts < te ≤ 1260
Addtl Info: records are tuples (t, n, m, s) where s is 0 or 1; queries are tuples (ts, te, m)