def shortest_tour(positions)
	positions.permutation(positions.size).map{|perm|
		([[0, 0]] + perm + [[0,0]]).each_cons(2).map{|p1, p2|
			x1, y1 = p1
			x2, y2 = p2
			(x1-x2).abs + (y1-y2).abs
		}.inject(:+)
	}.min
end

def multi_knapsack(items, budget)
	table = (0..1).map{ Array.new(budget+1, 0) }
	for i in 0..items.size-1
		c, v = items[i]
		for j in 0..budget
			table[1][j] = 0
			(0..j/c).each{|k|	
				x = table[0][j-k*c] + k*v
				table[1][j] = x if x > table[1][j]
			}
		end
		table << table.shift
	end
	table[0][budget]
end

n, m, w, t = gets.split.map &:to_i
items = {}
(1..m).each{ 
	name, weight, sale = gets.chomp.split
	items[name] = [weight.to_i, sale.to_i]
}

cities = (1..n).map{
	k, x, y = gets.split.map &:to_i
	city_items = {}
	(1..k).each{
		name, price = gets.chomp.split
		city_items[name] = price.to_i
	}
	[x, y, city_items]
}

time_profit = []
(1..(1<<n)-1).each{|x|
	idx = (0..n-1).select{|i| x[i] == 1}
	time = shortest_tour(idx.map{|i| cities[i][0..1]})
	available_items = Hash.new(0)
	idx.each{|i|
		city_items = cities[i][-1]
		city_items.each{|name, price|
			profit = items[name][1] - price
			available_items[name] = profit if profit > available_items[name]
		}
	}
	route_items = available_items.map{|name, profit| [items[name][0], profit]}
	total_profit = multi_knapsack(route_items, w)

	time_profit << [time, total_profit]
}

p multi_knapsack(time_profit, t)