#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

int dp[101][101];

int main() {
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			dp[i][j] = 1e9;
		}
	}
	int gx, gy, n, f;
	cin >> gx >> gy >> n >> f;
	dp[0][0] = 0;
	while (n--) {
		int x, y, c;
		cin >> x >> y >> c;
		for (int i = gx - x; i >= 0; i--) {
			for (int j = gy - y; j >= 0; j--) {
				dp[i + x][j + y] = min(dp[i + x][j + y], dp[i][j] + c);
			}
		}
	}
	int ans = 1e9;
	for (int i = 0; i <= gx; i++) {
		for (int j = 0; j <= gy; j++) {
			ans = min(ans, dp[i][j] + f * (abs(gx - i) + abs(gy - j)));
		}
	}
	cout << ans << endl;
}