#!/usr/bin/env python3 def solve(b, data: list[tuple[int, int, int]], plans: list[list[tuple[int, int]]]): INIT = (1 << 62) min_cost = [INIT for _ in range(b+1)] min_cost[0] = 0 for plans_ in plans: plans_.append((0, 0)) for ((p, r, s), plans_) in zip(data, plans): new_min_cost = [INIT for _ in range(b+1)] for end_bat in range(b+1): new_min = INIT for start_bat in range(b+1): for (c, d) in plans_: # how much do we need to buy? we need to have r+end_bat+d power, and we get s+start_bat for free # if the value is negative it means the end_bat is too low and we can't reach this number, so we # have to waste some power new_min = min( new_min, min_cost[start_bat] + (r + end_bat + d - s - start_bat) * p - c) # new_min_cost[end_bat] = min([ min_cost[start_bat] + (r + end_bat + d - s - start_bat) * p for start_bat in range(b+1)]) new_min_cost[end_bat] = new_min min_cost = new_min_cost return min(min_cost) n, m, b = tuple(map(int, input().split())) data = [map(int, input().split()) for _ in range(n)] c = [list(map(int, input().split())) for _ in range(n)] d = [list(map(int, input().split())) for _ in range(n)] plans = [list(zip(c_, d_)) for c_, d_ in zip(c, d)] print(solve(b, data, plans))