High-gain X-ray free electron laser by beat-wave terahertz undulator