n,m,k,t = map(int,input().split()) targ = n+m-2-t if targ <= 0: print(0) exit() ans = 10 ** 18 for i in range(k): a, b, c, d = map(int,input().split()) c -= 1 if c == 0: continue ans = min(ans, ((targ+c-1)//c) * d) if ans == 10 ** 18: print(-1) else: print(ans)