Extract labels and inputs in a single pass