Nonlinear dynamics of free electron terahertz lasers with bragg mirrors based on coupling of traveling and quasi-critical waves