import java.util.*;
import java.io.*;
class Main {
public static void main
(String[] args
) { Scanner scan
= new Scanner
(System.
in); // Integer count of number of items in the store
int count = scan.nextInt();
// Create an array to store names and prices of each item
double[] itemPrice = new double[count];
for (int i = 0; i < count; i++) {
// Scan name of each item and price
itemName[i] = scan.next();
itemPrice[i] = scan.nextDouble();
}
// Integer count for the number of customers
int numCustomers = scan.nextInt();
double[] costs = new double[numCustomers];
final Map
<String, Integer
> numBought
= new HashMap
<>(); final Map
<String, Integer
> peopleBought
= new HashMap
<>(); for (int j = 0; j < numCustomers; j++) {
// First and last name of each customer
nameF[j] = scan.next();
nameL[j] = scan.next();
// Number of items bought
int numItems = scan.nextInt();
for (int k = 0; k < numItems; k++) {
// For each number of items bought, name and quantity
int numItemBought = scan.nextInt();
String nameOfItem
= scan.
next(); numBought.
merge(nameOfItem, numItemBought,
Integer::sum
);// increase quantity of the item peopleBought.
merge(nameOfItem,
1,
Integer::sum
);// increment number of people who bought this item }
}
for (final String item
: itemName
) { final Integer num
= numBought.
get(item
); if (num == null) {
System.
out.
println("No one bought " + item
); } else {
System.
out.
println(peopleBought.
get(item
) + " bought " + num
+ " " + item
); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBzY2FuID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKICAgICAgICAvLyBJbnRlZ2VyIGNvdW50IG9mIG51bWJlciBvZiBpdGVtcyBpbiB0aGUgc3RvcmUKICAgICAgICBpbnQgY291bnQgPSBzY2FuLm5leHRJbnQoKTsKICAgICAgICAvLyBDcmVhdGUgYW4gYXJyYXkgdG8gc3RvcmUgbmFtZXMgYW5kIHByaWNlcyBvZiBlYWNoIGl0ZW0KICAgICAgICBTdHJpbmdbXSBpdGVtTmFtZSA9IG5ldyBTdHJpbmdbY291bnRdOwogICAgICAgIGRvdWJsZVtdIGl0ZW1QcmljZSA9IG5ldyBkb3VibGVbY291bnRdOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgewogICAgICAgICAgICAvLyBTY2FuIG5hbWUgb2YgZWFjaCBpdGVtIGFuZCBwcmljZQogICAgICAgICAgICBpdGVtTmFtZVtpXSA9IHNjYW4ubmV4dCgpOwogICAgICAgICAgICBpdGVtUHJpY2VbaV0gPSBzY2FuLm5leHREb3VibGUoKTsKICAgICAgICB9CiAgICAgICAgLy8gSW50ZWdlciBjb3VudCBmb3IgdGhlIG51bWJlciBvZiBjdXN0b21lcnMKICAgICAgICBpbnQgbnVtQ3VzdG9tZXJzID0gc2Nhbi5uZXh0SW50KCk7CiAgICAgICAgU3RyaW5nW10gbmFtZUYgPSBuZXcgU3RyaW5nW251bUN1c3RvbWVyc107CiAgICAgICAgU3RyaW5nW10gbmFtZUwgPSBuZXcgU3RyaW5nW251bUN1c3RvbWVyc107CiAgICAgICAgZG91YmxlW10gY29zdHMgPSBuZXcgZG91YmxlW251bUN1c3RvbWVyc107CiAgICAgICAgZmluYWwgTWFwPFN0cmluZywgSW50ZWdlcj4gbnVtQm91Z2h0ID0gbmV3IEhhc2hNYXA8PigpOwogICAgICAgIGZpbmFsIE1hcDxTdHJpbmcsIEludGVnZXI+IHBlb3BsZUJvdWdodCA9IG5ldyBIYXNoTWFwPD4oKTsKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG51bUN1c3RvbWVyczsgaisrKSB7CiAgICAgICAgICAgIC8vIEZpcnN0IGFuZCBsYXN0IG5hbWUgb2YgZWFjaCBjdXN0b21lcgogICAgICAgICAgICBuYW1lRltqXSA9IHNjYW4ubmV4dCgpOwogICAgICAgICAgICBuYW1lTFtqXSA9IHNjYW4ubmV4dCgpOwoKICAgICAgICAgICAgLy8gTnVtYmVyIG9mIGl0ZW1zIGJvdWdodAogICAgICAgICAgICBpbnQgbnVtSXRlbXMgPSBzY2FuLm5leHRJbnQoKTsKICAgICAgICAgICAgZm9yIChpbnQgayA9IDA7IGsgPCBudW1JdGVtczsgaysrKSB7CiAgICAgICAgICAgICAgICAvLyBGb3IgZWFjaCBudW1iZXIgb2YgaXRlbXMgYm91Z2h0LCBuYW1lIGFuZCBxdWFudGl0eQogICAgICAgICAgICAgICAgaW50IG51bUl0ZW1Cb3VnaHQgPSBzY2FuLm5leHRJbnQoKTsKICAgICAgICAgICAgICAgIFN0cmluZyBuYW1lT2ZJdGVtID0gc2Nhbi5uZXh0KCk7CiAgICAgICAgICAgICAgICBudW1Cb3VnaHQubWVyZ2UobmFtZU9mSXRlbSwgbnVtSXRlbUJvdWdodCwgSW50ZWdlcjo6c3VtKTsvLyBpbmNyZWFzZSBxdWFudGl0eSBvZiB0aGUgaXRlbQogICAgICAgICAgICAgICAgcGVvcGxlQm91Z2h0Lm1lcmdlKG5hbWVPZkl0ZW0sIDEsIEludGVnZXI6OnN1bSk7Ly8gaW5jcmVtZW50IG51bWJlciBvZiBwZW9wbGUgd2hvIGJvdWdodCB0aGlzIGl0ZW0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGZpbmFsIFN0cmluZyBpdGVtIDogaXRlbU5hbWUpIHsKICAgICAgICAgICAgZmluYWwgSW50ZWdlciBudW0gPSBudW1Cb3VnaHQuZ2V0KGl0ZW0pOwogICAgICAgICAgICBpZiAobnVtID09IG51bGwpIHsKICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTm8gb25lIGJvdWdodCAiICsgaXRlbSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4ocGVvcGxlQm91Z2h0LmdldChpdGVtKSArICIgYm91Z2h0ICIgKyBudW0gKyAiICIgKyBpdGVtKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQ==
NgoKQXBwbGUgMC4yNQoKQmFuYW5hIDAuNzUKCk1pbGsgMy4xNQoKT3JhbmdlIDEuMjUKClNhbGFtaSAyLjUwCgpTcG9uZ2UgMS4xNQoKMwoKQ2FsbGllIEJyb3duIDMgMiBCYW5hbmEgMSBPcmFuZ2UgMiBNaWxrCgpDaHJpcyBUdWNrZXIgMiAzIEJhbmFuYSAyIFNwb25nZQoKSmFuZSBXZWlzcyAxIDUgU2FsYW1p
6
Apple 0.25
Banana 0.75
Milk 3.15
Orange 1.25
Salami 2.50
Sponge 1.15
3
Callie Brown 3 2 Banana 1 Orange 2 Milk
Chris Tucker 2 3 Banana 2 Sponge
Jane Weiss 1 5 Salami