The addition of A and 5 is giving 2 i.e., a number whose ones digit is 2. This is possible only when digit A is 7. In that case, the addition of A (7) and 5 will give 12 and thus, 1 will be the carry for the next step. In the next step, 1 + 3 + 2 = 6

Therefore, the addition is as follows.

Clearly, B is 6.

Hence, A and B are 7 and 6 respectively.