## Editorial for Hearth

Remember to use this editorial

**only**when stuck, and**not to copy-paste code from it**. Please be respectful to the problem author and editorialist.**Submitting an official solution before solving the problem yourself is a bannable offence.**Since the bounds on are so small, we can simply use 3 for loops to check all possible combinations, appending all valid ones into a list, and then sorting everything. This problem is similar to a past CCC question, The Students' Council Breakfast.

```
n,t = map(int,raw_input().split())
cards = []
for i in range(n):
name,cost = raw_input().split()
cost = int(cost)
cards.append([name,cost])
works = []
for i in range(n-2):
for j in range(i+1,n-1):
for k in range(j+1,n):
if cards[i][1]+cards[j][1]+cards[k][1] <= t:
works.append(sorted([cards[i][0],cards[j][0],cards[k][0]]))
works.sort()
for i in works:
print i[0],i[1],i[2]
```

## Comments