parsed = {
const lines = input.trim().split('\n')
return new Map(lines.map(l => {
const [name, to] = l.replace(/ bags?/g, '').split(' contain ')
const children = to.split(', ')
.map(t => {
const [, n, name] = t.replace('.', '').match(/(\d+) (.*)/) || []
return n && {name, n: +n}
})
.filter(d => d)
return [name, children]
}))
}