The concept for this question and all other questions like this is as follows.
The router takes 1 IP address for every interface that it is connected to and the IP address is taken from the same subnet in which the whole network on that interface is.
So here every router is connected to 2 interfaces. Like R1 on the one side is connected to X and on the other side connected to R2. So similarly R2 is connected to R1 and Y.
So both the routers will be having 2 IP addresses. Both IPs in the interface should be in the same network.
So one side of the wire is X and on the second side is R2, So The default gateway for X will be the Ip address that belongs to the same subnet out of 2 IP which R1 has.
So you can get the Ip address router is using on the X side, remaining will be used to communicate by R2. Similarly, R2 has 2 IPs, check which is in the same subnet with the remaining IP of R1.