USing Diophantine equation method