import java.util.Collection; import java.util.Arrays; import java.util.Scanner; public class MAin { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Item[] niza = new Item[n]; for(int i = 0; i < n; i++) { double w = sc.nextDouble(); double v = sc.nextDouble(); niza[i] = new Item(w, v); } for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { if(niza[i].razmer < niza[j].razmer) { Item tmp = niza[i]; niza[i] = niza[j]; niza[j] = tmp; } } } double capacity = sc.nextDouble(); double totalValue = 0; for(int i = 0; i < n; i++) { if(capacity - niza[i].weight >= 0) { totalValue += niza[i].value; capacity -= niza[i].weight; } else { double del = capacity / niza[i].weight; totalValue += (del * niza[i].value); capacity -= (del * niza[i].weight); } } for(int i = 0; i < n; i++) { System.out.println(niza[i].weight + " " + niza[i].value + " " + niza[i].razmer); } System.out.println(totalValue); } static class Item { double weight, value; double razmer; Item(double weight, double value) { this.weight = weight; this.value = value; razmer = value / weight; } } } // 50- 10 - 20 = 20 // 60 + 100 +