reading separate inputs on digital pins, storing order and replaying as output

I suggest you post all your code. The way you define things like A will influence the answer.