Two powerful earthquakes a day apart shook southwestern Japan, killing at least 29 people, trapping many others beneath flattened homes and sending thousands of residents to seek refuge in gymnasiums and hotel lobbies.