human
Write me a code to find number of magical pairs of string of length L and the other steps required given the following:
Find number of magical pairs of string of length L | Iterative Function to calculate ( x ^ y ) % p in O ( log y ).
Initialize result.
Update x if it is >= p.
If y is odd , multiply x with result.
Y must be even now y = y >> 1.
y = y / 2.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to find number of magical pairs of string of length L and the other steps required.
 def power ( x , y , p ) :
	res = 1 ;
	x = x % p ;
	while ( y > 0 ) :
		if ( y % 2 == 1 ) :
			res = ( res * x ) % p ;
		x = ( x * x ) % p ;
	return res ;
L = 2 ; P = pow ( 10 , 9 ) ;
ans = power ( 325 , L , P ) ;
print ( ans ) ;