If you are preparing for this trip more than ten days in advance, you can book a room first, because you will get a preferential price if you book first. But remember to buy the train ticket immediately after booking the room, otherwise you may not get the ticket. If you are preparing for this trip one or two days in advance, it is best to buy a train ticket first. It is not certain whether you can get a ticket, and it is even more uncertain which day you will book a hotel.