TC, TH, VS, VF = input().split() N = int(input()) T = [] V = [] THVF = 0 THVS = 0 TCVF = 0 TCVS = 0 for i in range(0, N): TT , VV = input().split() T.append(TT) V.append(VV) count = 0 for i in T: if int(i) > int(TH): if int(V[count]) > int(VF): THVF += 1 elif int(V[count]) < int(VS): THVS += 1 if int(i) < int(TC): if int(V[count]) > int(VF): TCVF += 1 elif int(V[count]) < int(VS): TCVS += 1 count += 1 print(THVF) print(THVS) print(TCVF) print(TCVS)