Shell script to get this desired output

Hi there,

Attached is one image where data in input table is provided in a shell script and wanted to get desired output

Thanks is advace!

This needs more context.