Above elements are arranged according to their outer most shell.
Hydrogen - 1s1
Sodium - 1s22s22p63s1
Calcium - 1s22s22p63s23p64s2
Barium - [Xe] 6s2.
In sodium, the outer most shell is 3 whereas hydrogen has 1 whereas calcium is 4 and finally barium is 6. Hence we will match A to 4, B to 1, C to 2 and D to 3.