<?php 
	//include("serive/samparka.php"); //Remove IT
	$samasye = "SELECT atadaaidi
	  FROM gelluonduhogu_aidudi_funf
	  ORDER BY kramasankhye DESC LIMIT 1";//Add Kemuru
	$samasyephalitansa = $conn->query($samasye);
	$samasyesreni = mysqli_fetch_array($samasyephalitansa);
	//$samasyesreni['atadaaidi'] = 20240624010862;
	if(isset($samasyesreni['atadaaidi'])){
		$gadhipathuli = "SELECT ojana, ketebida
		  FROM bajikattuttate_aidudi_funf
		  WHERE kalaparichaya = ".$samasyesreni['atadaaidi']."
		  ORDER BY parichaya DESC LIMIT 1";
		$gadhipathuliphala = $conn->query($gadhipathuli);
		$gadhipathulidhadi = mysqli_num_rows($gadhipathuliphala);
		if($gadhipathulidhadi >= 1){
			$aqr = "SELECT ketebida FROM bajikattuttate_aidudi_funf WHERE prakar = '1' AND kalaparichaya = ".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
			$ars = $conn->query($aqr);
			$arw = mysqli_num_rows($ars);
			if($arw > 0){
				$sqlstr = "SELECT num 
					FROM ( 
						SELECT '0' AS num 
						UNION ALL 
						SELECT '1'
						UNION ALL 
						SELECT '2' 
						UNION ALL 
						SELECT '3' 
						UNION ALL 
						SELECT '4' 
						UNION ALL 
						SELECT '5' 
						UNION ALL 
						SELECT '6'
						UNION ALL 
						SELECT '7'
						UNION ALL 
						SELECT '8'
						UNION ALL 
						SELECT '9'
					) AS numbers 
					WHERE num NOT IN ( 
						SELECT '0' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%0%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL
						SELECT '1' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%1%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '2' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%2%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '3' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%3%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '4' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%4%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '5' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%5%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '6' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%6%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '7' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%7%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '8' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%8%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '9' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%9%' AND prakar = '1' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
					)";	
				$sqlstrans = $conn->query($sqlstr);
				$sqlstrnum = mysqli_num_rows($sqlstrans);
				if($sqlstrnum == 0){
					$difstr = "
						WITH sums AS (
							SELECT 
								SUM(CASE WHEN ojana LIKE '%0%' THEN ketebida ELSE 0 END) AS sum_0,
								SUM(CASE WHEN ojana LIKE '%1%' THEN ketebida ELSE 0 END) AS sum_1,
								SUM(CASE WHEN ojana LIKE '%2%' THEN ketebida ELSE 0 END) AS sum_2,
								SUM(CASE WHEN ojana LIKE '%3%' THEN ketebida ELSE 0 END) AS sum_3,
								SUM(CASE WHEN ojana LIKE '%4%' THEN ketebida ELSE 0 END) AS sum_4,
								SUM(CASE WHEN ojana LIKE '%5%' THEN ketebida ELSE 0 END) AS sum_5,
								SUM(CASE WHEN ojana LIKE '%6%' THEN ketebida ELSE 0 END) AS sum_6,
								SUM(CASE WHEN ojana LIKE '%7%' THEN ketebida ELSE 0 END) AS sum_7,
								SUM(CASE WHEN ojana LIKE '%8%' THEN ketebida ELSE 0 END) AS sum_8,
								SUM(CASE WHEN ojana LIKE '%9%' THEN ketebida ELSE 0 END) AS sum_9
							FROM 
								bajikattuttate_aidudi_funf
							WHERE 
								prakar = '1' 
								AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi']."
						), min_sums AS (
							SELECT '0' AS number, sum_0 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '1' AS number, sum_1 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '2' AS number, sum_2 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '3' AS number, sum_3 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '4' AS number, sum_4 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '5' AS number, sum_5 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '6' AS number, sum_6 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '7' AS number, sum_7 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '8' AS number, sum_8 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '9' AS number, sum_9 AS ketebida_sum FROM sums
						), minimum AS (
							SELECT
								MIN(ketebida_sum) AS minimum_ketebida
							FROM
								min_sums
						)
						SELECT
							number,
							ketebida_sum
						FROM
							min_sums
						WHERE
							ketebida_sum = (SELECT minimum_ketebida FROM minimum)
						ORDER BY
							RAND()
						LIMIT 1
					";
					$difstrans = $conn->query($difstr);
					$firstnumarr = mysqli_fetch_array($difstrans);
					$yadrcchika_a = $firstnumarr['number'];
					
					$a_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_big_rs = $conn->query($a_big_qr);
					$a_big_ar = mysqli_fetch_array($a_big_rs);
					$a_big = $a_big_ar['a_big'];
					
					$a_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_small_rs = $conn->query($a_small_qr);
					$a_small_ar = mysqli_fetch_array($a_small_rs);
					$a_small = $a_small_ar['a_small'];
					
					$a_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_odd_rs = $conn->query($a_odd_qr);
					$a_odd_ar = mysqli_fetch_array($a_odd_rs);
					$a_odd = $a_odd_ar['a_odd'];
					
					$a_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_even_rs = $conn->query($a_even_qr);
					$a_even_ar = mysqli_fetch_array($a_even_rs);
					$a_even = $a_even_ar['a_even'];
					
					$a_top = $a_big + $a_small + $a_odd + $a_even;
					
					$a_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x61\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_num_rs = $conn->query($a_num_qr);
					$a_num_ar = mysqli_fetch_array($a_num_rs);
					$a_num = $a_num_ar['a_num'];
					
					if($a_num < $a_top){
						if($a_big < $a_small){
							if($a_odd < $a_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_a = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_a = $even_ar[$even_key];
							}
						}
						else{
							if($a_odd < $a_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_a = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_a = $even_ar[$even_key];
							}
						}
					}
				}
				else{
					$dif = array();
					while($row = mysqli_fetch_array($sqlstrans)){
						$dif[] = $row['num'];						
					}
					$key = array_rand($dif,1);
					$yadrcchika_a = $dif[$key];
					
					$a_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_big_rs = $conn->query($a_big_qr);
					$a_big_ar = mysqli_fetch_array($a_big_rs);
					$a_big = $a_big_ar['a_big'];
					
					$a_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_small_rs = $conn->query($a_small_qr);
					$a_small_ar = mysqli_fetch_array($a_small_rs);
					$a_small = $a_small_ar['a_small'];
					
					$a_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_odd_rs = $conn->query($a_odd_qr);
					$a_odd_ar = mysqli_fetch_array($a_odd_rs);
					$a_odd = $a_odd_ar['a_odd'];
					
					$a_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x61\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_even_rs = $conn->query($a_even_qr);
					$a_even_ar = mysqli_fetch_array($a_even_rs);
					$a_even = $a_even_ar['a_even'];
					
					$a_top = $a_big + $a_small + $a_odd + $a_even;
					
					$a_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x61\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x31\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$a_num_rs = $conn->query($a_num_qr);
					$a_num_ar = mysqli_fetch_array($a_num_rs);
					$a_num = $a_num_ar['a_num'];
					
					if($a_num < $a_top){
						if($a_big < $a_small){
							if($a_odd < $a_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_a = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_a = $even_ar[$even_key];
							}
						}
						else{
							if($a_odd < $a_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_a = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_a = $even_ar[$even_key];
							}
						}
					}
				}
			}
			else{
				$yadrcchika_a = rand(0, 9);
			}
			
			$bqr = "SELECT ketebida FROM bajikattuttate_aidudi_funf WHERE prakar = '2' AND kalaparichaya = ".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
			$brs = $conn->query($bqr);
			$brw = mysqli_num_rows($brs);
			if($brw > 0){
				$sqlstr = "SELECT num 
					FROM ( 
						SELECT '0' AS num 
						UNION ALL 
						SELECT '1'
						UNION ALL 
						SELECT '2' 
						UNION ALL 
						SELECT '3' 
						UNION ALL 
						SELECT '4' 
						UNION ALL 
						SELECT '5' 
						UNION ALL 
						SELECT '6'
						UNION ALL 
						SELECT '7'
						UNION ALL 
						SELECT '8'
						UNION ALL 
						SELECT '9'
					) AS numbers 
					WHERE num NOT IN ( 
						SELECT '0' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%0%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL
						SELECT '1' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%1%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '2' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%2%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '3' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%3%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '4' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%4%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '5' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%5%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '6' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%6%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '7' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%7%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '8' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%8%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '9' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%9%' AND prakar = '2' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
					)";	
				$sqlstrans = $conn->query($sqlstr);
				$sqlstrnum = mysqli_num_rows($sqlstrans);
				if($sqlstrnum == 0){
					$difstr = "
						WITH sums AS (
							SELECT 
								SUM(CASE WHEN ojana LIKE '%0%' THEN ketebida ELSE 0 END) AS sum_0,
								SUM(CASE WHEN ojana LIKE '%1%' THEN ketebida ELSE 0 END) AS sum_1,
								SUM(CASE WHEN ojana LIKE '%2%' THEN ketebida ELSE 0 END) AS sum_2,
								SUM(CASE WHEN ojana LIKE '%3%' THEN ketebida ELSE 0 END) AS sum_3,
								SUM(CASE WHEN ojana LIKE '%4%' THEN ketebida ELSE 0 END) AS sum_4,
								SUM(CASE WHEN ojana LIKE '%5%' THEN ketebida ELSE 0 END) AS sum_5,
								SUM(CASE WHEN ojana LIKE '%6%' THEN ketebida ELSE 0 END) AS sum_6,
								SUM(CASE WHEN ojana LIKE '%7%' THEN ketebida ELSE 0 END) AS sum_7,
								SUM(CASE WHEN ojana LIKE '%8%' THEN ketebida ELSE 0 END) AS sum_8,
								SUM(CASE WHEN ojana LIKE '%9%' THEN ketebida ELSE 0 END) AS sum_9
							FROM 
								bajikattuttate_aidudi_funf
							WHERE 
								prakar = '2' 
								AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi']."
						), min_sums AS (
							SELECT '0' AS number, sum_0 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '1' AS number, sum_1 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '2' AS number, sum_2 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '3' AS number, sum_3 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '4' AS number, sum_4 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '5' AS number, sum_5 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '6' AS number, sum_6 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '7' AS number, sum_7 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '8' AS number, sum_8 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '9' AS number, sum_9 AS ketebida_sum FROM sums
						), minimum AS (
							SELECT
								MIN(ketebida_sum) AS minimum_ketebida
							FROM
								min_sums
						)
						SELECT
							number,
							ketebida_sum
						FROM
							min_sums
						WHERE
							ketebida_sum = (SELECT minimum_ketebida FROM minimum)
						ORDER BY
							RAND()
						LIMIT 1
					";
					$difstrans = $conn->query($difstr);
					$firstnumarr = mysqli_fetch_array($difstrans);
					$yadrcchika_b = $firstnumarr['number'];
					
					$b_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_big_rs = $conn->query($b_big_qr);
					$b_big_ar = mysqli_fetch_array($b_big_rs);
					$b_big = $b_big_ar['b_big'];
					
					$b_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_small_rs = $conn->query($b_small_qr);
					$b_small_ar = mysqli_fetch_array($b_small_rs);
					$b_small = $b_small_ar['b_small'];
					
					$b_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_odd_rs = $conn->query($b_odd_qr);
					$b_odd_ar = mysqli_fetch_array($b_odd_rs);
					$b_odd = $b_odd_ar['b_odd'];
					
					$b_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_even_rs = $conn->query($b_even_qr);
					$b_even_ar = mysqli_fetch_array($b_even_rs);
					$b_even = $b_even_ar['b_even'];
					
					$b_top = $b_big + $b_small + $b_odd + $b_even;
					
					$b_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x62\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_num_rs = $conn->query($b_num_qr);
					$b_num_ar = mysqli_fetch_array($b_num_rs);
					$b_num = $b_num_ar['b_num'];
					
					if($b_num < $b_top){
						if($b_big < $b_small){
							if($b_odd < $b_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_b = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_b = $even_ar[$even_key];
							}
						}
						else{
							if($b_odd < $b_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_b = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_b = $even_ar[$even_key];
							}
						}
					}
				}
				else{
					$dif = array();
					while($row = mysqli_fetch_array($sqlstrans)){
						$dif[] = $row['num'];						
					}
					$key = array_rand($dif,1);
					$yadrcchika_b = $dif[$key];
					
					$b_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_big_rs = $conn->query($b_big_qr);
					$b_big_ar = mysqli_fetch_array($b_big_rs);
					$b_big = $b_big_ar['b_big'];
					
					$b_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_small_rs = $conn->query($b_small_qr);
					$b_small_ar = mysqli_fetch_array($b_small_rs);
					$b_small = $b_small_ar['b_small'];
					
					$b_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_odd_rs = $conn->query($b_odd_qr);
					$b_odd_ar = mysqli_fetch_array($b_odd_rs);
					$b_odd = $b_odd_ar['b_odd'];
					
					$b_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x62\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_even_rs = $conn->query($b_even_qr);
					$b_even_ar = mysqli_fetch_array($b_even_rs);
					$b_even = $b_even_ar['b_even'];
					
					$b_top = $b_big + $b_small + $b_odd + $b_even;
					
					$b_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x62\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x32\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$b_num_rs = $conn->query($b_num_qr);
					$b_num_ar = mysqli_fetch_array($b_num_rs);
					$b_num = $b_num_ar['b_num'];
					
					if($b_num < $b_top){
						if($b_big < $b_small){
							if($b_odd < $b_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_b = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_b = $even_ar[$even_key];
							}
						}
						else{
							if($b_odd < $b_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_b = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_b = $even_ar[$even_key];
							}
						}
					}
				}
			}
			else{
				$yadrcchika_b = rand(0, 9);
			}
			
			$cqr = "SELECT ketebida FROM bajikattuttate_aidudi_funf WHERE prakar = '3' AND kalaparichaya = ".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
			$crs = $conn->query($cqr);
			$crw = mysqli_num_rows($crs);
			if($crw > 0){
				$sqlstr = "SELECT num 
					FROM ( 
						SELECT '0' AS num 
						UNION ALL 
						SELECT '1'
						UNION ALL 
						SELECT '2' 
						UNION ALL 
						SELECT '3' 
						UNION ALL 
						SELECT '4' 
						UNION ALL 
						SELECT '5' 
						UNION ALL 
						SELECT '6'
						UNION ALL 
						SELECT '7'
						UNION ALL 
						SELECT '8'
						UNION ALL 
						SELECT '9'
					) AS numbers 
					WHERE num NOT IN ( 
						SELECT '0' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%0%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL
						SELECT '1' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%1%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '2' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%2%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '3' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%3%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '4' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%4%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '5' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%5%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '6' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%6%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '7' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%7%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '8' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%8%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '9' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%9%' AND prakar = '3' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
					)";	
				$sqlstrans = $conn->query($sqlstr);
				$sqlstrnum = mysqli_num_rows($sqlstrans);
				if($sqlstrnum == 0){
					$difstr = "
						WITH sums AS (
							SELECT 
								SUM(CASE WHEN ojana LIKE '%0%' THEN ketebida ELSE 0 END) AS sum_0,
								SUM(CASE WHEN ojana LIKE '%1%' THEN ketebida ELSE 0 END) AS sum_1,
								SUM(CASE WHEN ojana LIKE '%2%' THEN ketebida ELSE 0 END) AS sum_2,
								SUM(CASE WHEN ojana LIKE '%3%' THEN ketebida ELSE 0 END) AS sum_3,
								SUM(CASE WHEN ojana LIKE '%4%' THEN ketebida ELSE 0 END) AS sum_4,
								SUM(CASE WHEN ojana LIKE '%5%' THEN ketebida ELSE 0 END) AS sum_5,
								SUM(CASE WHEN ojana LIKE '%6%' THEN ketebida ELSE 0 END) AS sum_6,
								SUM(CASE WHEN ojana LIKE '%7%' THEN ketebida ELSE 0 END) AS sum_7,
								SUM(CASE WHEN ojana LIKE '%8%' THEN ketebida ELSE 0 END) AS sum_8,
								SUM(CASE WHEN ojana LIKE '%9%' THEN ketebida ELSE 0 END) AS sum_9
							FROM 
								bajikattuttate_aidudi_funf
							WHERE 
								prakar = '3' 
								AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi']."
						), min_sums AS (
							SELECT '0' AS number, sum_0 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '1' AS number, sum_1 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '2' AS number, sum_2 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '3' AS number, sum_3 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '4' AS number, sum_4 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '5' AS number, sum_5 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '6' AS number, sum_6 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '7' AS number, sum_7 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '8' AS number, sum_8 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '9' AS number, sum_9 AS ketebida_sum FROM sums
						), minimum AS (
							SELECT
								MIN(ketebida_sum) AS minimum_ketebida
							FROM
								min_sums
						)
						SELECT
							number,
							ketebida_sum
						FROM
							min_sums
						WHERE
							ketebida_sum = (SELECT minimum_ketebida FROM minimum)
						ORDER BY
							RAND()
						LIMIT 1
					";
					$difstrans = $conn->query($difstr);
					$firstnumarr = mysqli_fetch_array($difstrans);
					$yadrcchika_c = $firstnumarr['number'];
					
					$c_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_big_rs = $conn->query($c_big_qr);
					$c_big_ar = mysqli_fetch_array($c_big_rs);
					$c_big = $c_big_ar['c_big'];
					
					$c_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_small_rs = $conn->query($c_small_qr);
					$c_small_ar = mysqli_fetch_array($c_small_rs);
					$c_small = $c_small_ar['c_small'];
					
					$c_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_odd_rs = $conn->query($c_odd_qr);
					$c_odd_ar = mysqli_fetch_array($c_odd_rs);
					$c_odd = $c_odd_ar['c_odd'];
					
					$c_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_even_rs = $conn->query($c_even_qr);
					$c_even_ar = mysqli_fetch_array($c_even_rs);
					$c_even = $c_even_ar['c_even'];
					
					$c_top = $c_big + $c_small + $c_odd + $c_even;
					
					$c_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x63\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_num_rs = $conn->query($c_num_qr);
					$c_num_ar = mysqli_fetch_array($c_num_rs);
					$c_num = $c_num_ar['c_num'];
					
					if($c_num < $c_top){
						if($c_big < $c_small){
							if($c_odd < $c_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_c = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_c = $even_ar[$even_key];
							}
						}
						else{
							if($c_odd < $c_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_c = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_c = $even_ar[$even_key];
							}
						}
					}
				}
				else{
					$dif = array();
					while($row = mysqli_fetch_array($sqlstrans)){
						$dif[] = $row['num'];						
					}
					$key = array_rand($dif,1);
					$yadrcchika_c = $dif[$key];
					
					$c_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_big_rs = $conn->query($c_big_qr);
					$c_big_ar = mysqli_fetch_array($c_big_rs);
					$c_big = $c_big_ar['c_big'];
					
					$c_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_small_rs = $conn->query($c_small_qr);
					$c_small_ar = mysqli_fetch_array($c_small_rs);
					$c_small = $c_small_ar['c_small'];
					
					$c_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_odd_rs = $conn->query($c_odd_qr);
					$c_odd_ar = mysqli_fetch_array($c_odd_rs);
					$c_odd = $c_odd_ar['c_odd'];
					
					$c_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x63\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_even_rs = $conn->query($c_even_qr);
					$c_even_ar = mysqli_fetch_array($c_even_rs);
					$c_even = $c_even_ar['c_even'];
					
					$c_top = $c_big + $c_small + $c_odd + $c_even;
					
					$c_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x63\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x33\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$c_num_rs = $conn->query($c_num_qr);
					$c_num_ar = mysqli_fetch_array($c_num_rs);
					$c_num = $c_num_ar['c_num'];
					
					if($c_num < $c_top){
						if($c_big < $c_small){
							if($c_odd < $c_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_c = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_c = $even_ar[$even_key];
							}
						}
						else{
							if($c_odd < $c_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_c = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_c = $even_ar[$even_key];
							}
						}
					}
				}
			}
			else{
				$yadrcchika_c = rand(0, 9);
			}
			
			$dqr = "SELECT ketebida FROM bajikattuttate_aidudi_funf WHERE prakar = '4' AND kalaparichaya = ".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
			$drs = $conn->query($dqr);
			$drw = mysqli_num_rows($drs);
			if($drw > 0){
				$sqlstr = "SELECT num 
					FROM ( 
						SELECT '0' AS num 
						UNION ALL 
						SELECT '1'
						UNION ALL 
						SELECT '2' 
						UNION ALL 
						SELECT '3' 
						UNION ALL 
						SELECT '4' 
						UNION ALL 
						SELECT '5' 
						UNION ALL 
						SELECT '6'
						UNION ALL 
						SELECT '7'
						UNION ALL 
						SELECT '8'
						UNION ALL 
						SELECT '9'
					) AS numbers 
					WHERE num NOT IN ( 
						SELECT '0' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%0%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL
						SELECT '1' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%1%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '2' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%2%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '3' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%3%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '4' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%4%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '5' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%5%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '6' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%6%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '7' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%7%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '8' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%8%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '9' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%9%' AND prakar = '4' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
					)";	
				$sqlstrans = $conn->query($sqlstr);
				$sqlstrnum = mysqli_num_rows($sqlstrans);
				if($sqlstrnum == 0){
					$difstr = "
						WITH sums AS (
							SELECT 
								SUM(CASE WHEN ojana LIKE '%0%' THEN ketebida ELSE 0 END) AS sum_0,
								SUM(CASE WHEN ojana LIKE '%1%' THEN ketebida ELSE 0 END) AS sum_1,
								SUM(CASE WHEN ojana LIKE '%2%' THEN ketebida ELSE 0 END) AS sum_2,
								SUM(CASE WHEN ojana LIKE '%3%' THEN ketebida ELSE 0 END) AS sum_3,
								SUM(CASE WHEN ojana LIKE '%4%' THEN ketebida ELSE 0 END) AS sum_4,
								SUM(CASE WHEN ojana LIKE '%5%' THEN ketebida ELSE 0 END) AS sum_5,
								SUM(CASE WHEN ojana LIKE '%6%' THEN ketebida ELSE 0 END) AS sum_6,
								SUM(CASE WHEN ojana LIKE '%7%' THEN ketebida ELSE 0 END) AS sum_7,
								SUM(CASE WHEN ojana LIKE '%8%' THEN ketebida ELSE 0 END) AS sum_8,
								SUM(CASE WHEN ojana LIKE '%9%' THEN ketebida ELSE 0 END) AS sum_9
							FROM 
								bajikattuttate_aidudi_funf
							WHERE 
								prakar = '4' 
								AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi']."
						), min_sums AS (
							SELECT '0' AS number, sum_0 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '1' AS number, sum_1 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '2' AS number, sum_2 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '3' AS number, sum_3 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '4' AS number, sum_4 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '5' AS number, sum_5 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '6' AS number, sum_6 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '7' AS number, sum_7 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '8' AS number, sum_8 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '9' AS number, sum_9 AS ketebida_sum FROM sums
						), minimum AS (
							SELECT
								MIN(ketebida_sum) AS minimum_ketebida
							FROM
								min_sums
						)
						SELECT
							number,
							ketebida_sum
						FROM
							min_sums
						WHERE
							ketebida_sum = (SELECT minimum_ketebida FROM minimum)
						ORDER BY
							RAND()
						LIMIT 1
					";
					$difstrans = $conn->query($difstr);
					$firstnumarr = mysqli_fetch_array($difstrans);
					$yadrcchika_d = $firstnumarr['number'];
					
					$d_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_big_rs = $conn->query($d_big_qr);
					$d_big_ar = mysqli_fetch_array($d_big_rs);
					$d_big = $d_big_ar['d_big'];
					
					$d_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_small_rs = $conn->query($d_small_qr);
					$d_small_ar = mysqli_fetch_array($d_small_rs);
					$d_small = $d_small_ar['d_small'];
					
					$d_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_odd_rs = $conn->query($d_odd_qr);
					$d_odd_ar = mysqli_fetch_array($d_odd_rs);
					$d_odd = $d_odd_ar['d_odd'];
					
					$d_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_even_rs = $conn->query($d_even_qr);
					$d_even_ar = mysqli_fetch_array($d_even_rs);
					$d_even = $d_even_ar['d_even'];
					
					$d_top = $d_big + $d_small + $d_odd + $d_even;
					
					$d_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x64\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_num_rs = $conn->query($d_num_qr);
					$d_num_ar = mysqli_fetch_array($d_num_rs);
					$d_num = $d_num_ar['d_num'];
					
					if($d_num < $d_top){
						if($d_big < $d_small){
							if($d_odd < $d_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_d = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_d = $even_ar[$even_key];
							}
						}
						else{
							if($d_odd < $d_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_d = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_d = $even_ar[$even_key];
							}
						}
					}
				}
				else{
					$dif = array();
					while($row = mysqli_fetch_array($sqlstrans)){
						$dif[] = $row['num'];						
					}
					$key = array_rand($dif,1);
					$yadrcchika_d = $dif[$key];
					
					$d_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_big_rs = $conn->query($d_big_qr);
					$d_big_ar = mysqli_fetch_array($d_big_rs);
					$d_big = $d_big_ar['d_big'];
					
					$d_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_small_rs = $conn->query($d_small_qr);
					$d_small_ar = mysqli_fetch_array($d_small_rs);
					$d_small = $d_small_ar['d_small'];
					
					$d_odd_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_odd_rs = $conn->query($d_odd_qr);
					$d_odd_ar = mysqli_fetch_array($d_odd_rs);
					$d_odd = $d_odd_ar['d_odd'];
					
					$d_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x64\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_even_rs = $conn->query($d_even_qr);
					$d_even_ar = mysqli_fetch_array($d_even_rs);
					$d_even = $d_even_ar['d_even'];
					
					$d_top = $d_big + $d_small + $d_odd + $d_even;
					
					$d_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x64\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x34\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$d_num_rs = $conn->query($d_num_qr);
					$d_num_ar = mysqli_fetch_array($d_num_rs);
					$d_num = $d_num_ar['d_num'];
					
					if($d_num < $d_top){
						if($d_big < $d_small){
							if($d_odd < $d_even){
								$odd_ar = [5, 7, 9];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_d = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_d = $even_ar[$even_key];
							}
						}
						else{
							if($d_odd < $d_even){
								$odd_ar = [1, 3];
								$odd_key = array_rand($odd_ar,1);
								$yadrcchika_d = $odd_ar[$odd_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_d = $even_ar[$even_key];
							}
						}
					}
				}
			}
			else{
				$yadrcchika_d = rand(0, 9);
			}
			
			$eqr = "SELECT ketebida FROM bajikattuttate_aidudi_funf WHERE prakar = '5' AND kalaparichaya = ".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
			$ers = $conn->query($eqr);
			$erw = mysqli_num_rows($ers);
			if($erw > 0){
				$sqlstr = "SELECT num 
					FROM ( 
						SELECT '0' AS num 
						UNION ALL 
						SELECT '1'
						UNION ALL 
						SELECT '2' 
						UNION ALL 
						SELECT '3' 
						UNION ALL 
						SELECT '4' 
						UNION ALL 
						SELECT '5' 
						UNION ALL 
						SELECT '6'
						UNION ALL 
						SELECT '7'
						UNION ALL 
						SELECT '8'
						UNION ALL 
						SELECT '9'
					) AS numbers 
					WHERE num NOT IN ( 
						SELECT '0' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%0%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL
						SELECT '1' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%1%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '2' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%2%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '3' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%3%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '4' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%4%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '5' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%5%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].") 
						UNION ALL 
						SELECT '6' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%6%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '7' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%7%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '8' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%8%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
						UNION ALL 
						SELECT '9' WHERE EXISTS (SELECT 1 FROM bajikattuttate_aidudi_funf WHERE ojana LIKE '%9%' AND prakar = '5' AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi'].")
					)";	
				$sqlstrans = $conn->query($sqlstr);
				$sqlstrnum = mysqli_num_rows($sqlstrans);
				if($sqlstrnum == 0){
					$difstr = "
						WITH sums AS (
							SELECT 
								SUM(CASE WHEN ojana LIKE '%0%' THEN ketebida ELSE 0 END) AS sum_0,
								SUM(CASE WHEN ojana LIKE '%1%' THEN ketebida ELSE 0 END) AS sum_1,
								SUM(CASE WHEN ojana LIKE '%2%' THEN ketebida ELSE 0 END) AS sum_2,
								SUM(CASE WHEN ojana LIKE '%3%' THEN ketebida ELSE 0 END) AS sum_3,
								SUM(CASE WHEN ojana LIKE '%4%' THEN ketebida ELSE 0 END) AS sum_4,
								SUM(CASE WHEN ojana LIKE '%5%' THEN ketebida ELSE 0 END) AS sum_5,
								SUM(CASE WHEN ojana LIKE '%6%' THEN ketebida ELSE 0 END) AS sum_6,
								SUM(CASE WHEN ojana LIKE '%7%' THEN ketebida ELSE 0 END) AS sum_7,
								SUM(CASE WHEN ojana LIKE '%8%' THEN ketebida ELSE 0 END) AS sum_8,
								SUM(CASE WHEN ojana LIKE '%9%' THEN ketebida ELSE 0 END) AS sum_9
							FROM 
								bajikattuttate_aidudi_funf
							WHERE 
								prakar = '5' 
								AND \x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29\x20\x41\x4e\x44\x20 kalaparichaya = ".$samasyesreni['atadaaidi']."
						), min_sums AS (
							SELECT '0' AS number, sum_0 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '1' AS number, sum_1 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '2' AS number, sum_2 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '3' AS number, sum_3 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '4' AS number, sum_4 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '5' AS number, sum_5 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '6' AS number, sum_6 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '7' AS number, sum_7 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '8' AS number, sum_8 AS ketebida_sum FROM sums
							UNION ALL
							SELECT '9' AS number, sum_9 AS ketebida_sum FROM sums
						), minimum AS (
							SELECT
								MIN(ketebida_sum) AS minimum_ketebida
							FROM
								min_sums
						)
						SELECT
							number,
							ketebida_sum
						FROM
							min_sums
						WHERE
							ketebida_sum = (SELECT minimum_ketebida FROM minimum)
						ORDER BY
							RAND()
						LIMIT 1
					";
					$difstrans = $conn->query($difstr);
					$firstnumarr = mysqli_fetch_array($difstrans);
					$yadrcchika_e = $firstnumarr['number'];
					
					$e_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_big_rs = $conn->query($e_big_qr);
					$e_big_ar = mysqli_fetch_array($e_big_rs);
					$e_big = $e_big_ar['e_big'];
					
					$e_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_small_rs = $conn->query($e_small_qr);
					$e_small_ar = mysqli_fetch_array($e_small_rs);
					$e_small = $e_small_ar['e_small'];
					
					$e_ode_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_ode_rs = $conn->query($e_ode_qr);
					$e_ode_ar = mysqli_fetch_array($e_ode_rs);
					$e_odd = $e_ode_ar['e_odd'];
					
					$e_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_even_rs = $conn->query($e_even_qr);
					$e_even_ar = mysqli_fetch_array($e_even_rs);
					$e_even = $e_even_ar['e_even'];
					
					$e_top = $e_big + $e_small + $e_odd + $e_even;
					
					$e_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x65\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_num_rs = $conn->query($e_num_qr);
					$e_num_ar = mysqli_fetch_array($e_num_rs);
					$e_num = $e_num_ar['e_num'];
					
					if($e_num < $e_top){
						if($e_big < $e_small){
							if($e_odd < $e_even){
								$ode_ar = [5, 7, 9];
								$ode_key = array_rand($ode_ar,1);
								$yadrcchika_e = $ode_ar[$ode_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_e = $even_ar[$even_key];
							}
						}
						else{
							if($e_odd < $e_even){
								$ode_ar = [1, 3];
								$ode_key = array_rand($ode_ar,1);
								$yadrcchika_e = $ode_ar[$ode_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_e = $even_ar[$even_key];
							}
						}
					}
				}
				else{
					$dif = array();
					while($row = mysqli_fetch_array($sqlstrans)){
						$dif[] = $row['num'];						
					}
					$key = array_rand($dif,1);
					$yadrcchika_e = $dif[$key];
					
					$e_big_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x62\x69\x67\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_big_rs = $conn->query($e_big_qr);
					$e_big_ar = mysqli_fetch_array($e_big_rs);
					$e_big = $e_big_ar['e_big'];
					
					$e_small_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x73\x6d\x61\x6c\x6c\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_small_rs = $conn->query($e_small_qr);
					$e_small_ar = mysqli_fetch_array($e_small_rs);
					$e_small = $e_small_ar['e_small'];
					
					$e_ode_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x6f\x64\x64\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_ode_rs = $conn->query($e_ode_qr);
					$e_ode_ar = mysqli_fetch_array($e_ode_rs);
					$e_odd = $e_ode_ar['e_odd'];
					
					$e_even_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6b\x65\x74\x65\x62\x69\x64\x61\x29\x20\x61\x73\x20\x65\x5f\x65\x76\x65\x6e\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x3d\x20\x27\x45\x27\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_even_rs = $conn->query($e_even_qr);
					$e_even_ar = mysqli_fetch_array($e_even_rs);
					$e_even = $e_even_ar['e_even'];
					
					$e_top = $e_big + $e_small + $e_odd + $e_even;
					
					$e_num_qr = "\x53\x45\x4c\x45\x43\x54\x20\x53\x55\x4d\x28\x6d\x65\x6e\x67\x65\x20\x2a\x20\x77\x65\x74\x74\x61\x6e\x7a\x61\x68\x6c\x29\x20\x61\x73\x20\x65\x5f\x6e\x75\x6d\x20\x46\x52\x4f\x4d\x20\x62\x61\x6a\x69\x6b\x61\x74\x74\x75\x74\x74\x61\x74\x65\x5f\x61\x69\x64\x75\x64\x69\x5f\x66\x75\x6e\x66\x20\x57\x48\x45\x52\x45\x20\x70\x72\x61\x6b\x61\x72\x20\x3d\x20\x27\x35\x27\x20\x41\x4e\x44\x20\x28\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x48\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4c\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x4f\x27\x20\x41\x4e\x44\x20\x6f\x6a\x61\x6e\x61\x20\x21\x3d\x20\x27\x45\x27\x29\x20\x41\x4e\x44\x20\x6b\x61\x6c\x61\x70\x61\x72\x69\x63\x68\x61\x79\x61\x20\x3d\x20".$samasyesreni['atadaaidi']."\x20\x41\x4e\x44\x20\x62\x79\x61\x62\x61\x68\x61\x72\x6b\x61\x72\x74\x61\x20\x4e\x4f\x54\x20\x49\x4e\x20\x28\x53\x45\x4c\x45\x43\x54\x20\x62\x61\x6c\x61\x6b\x65\x64\x61\x72\x61\x20\x46\x52\x4f\x4d\x20\x60\x64\x65\x6d\x6f\x60\x20\x57\x48\x45\x52\x45\x20\x60\x73\x74\x68\x69\x74\x69\x60\x3d\x27\x31\x27\x29";
					$e_num_rs = $conn->query($e_num_qr);
					$e_num_ar = mysqli_fetch_array($e_num_rs);
					$e_num = $e_num_ar['e_num'];
					
					if($e_num < $e_top){
						if($e_big < $e_small){
							if($e_odd < $e_even){
								$ode_ar = [5, 7, 9];
								$ode_key = array_rand($ode_ar,1);
								$yadrcchika_e = $ode_ar[$ode_key];
							}
							else{
								$even_ar = [6, 8];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_e = $even_ar[$even_key];
							}
						}
						else{
							if($e_odd < $e_even){
								$ode_ar = [1, 3];
								$ode_key = array_rand($ode_ar,1);
								$yadrcchika_e = $ode_ar[$ode_key];
							}
							else{
								$even_ar = [0, 2, 4];
								$even_key = array_rand($even_ar,1);
								$yadrcchika_e = $even_ar[$even_key];
							}
						}
					}
				}
			}
			else{
				$yadrcchika_e = rand(0, 9);
			}
			$yadrcchika_final = $yadrcchika_a.$yadrcchika_b.$yadrcchika_c.$yadrcchika_d.$yadrcchika_e;
			$yadrcchika_sum = $yadrcchika_a + $yadrcchika_b + $yadrcchika_c + $yadrcchika_d + $yadrcchika_e;
			
			$pachare = mysqli_query($conn,"SELECT sankhye FROM `hastacalita_phalitansa_aidudi_funf` WHERE sthiti = '1' LIMIT 1");
			$achiki = mysqli_num_rows($pachare);
			if($achiki == 1){
				$thaka = mysqli_fetch_array($pachare);
				$kadimesucyanka = $thaka['sankhye'];
				$characters = str_split($kadimesucyanka);
				$yadrcchika_a = $characters[0];
				$yadrcchika_b = $characters[1];
				$yadrcchika_c = $characters[2];
				$yadrcchika_d = $characters[3];
				$yadrcchika_e = $characters[4];
				$yadrcchika_final = $kadimesucyanka;
				$yadrcchika_sum = $yadrcchika_a + $yadrcchika_b + $yadrcchika_c + $yadrcchika_d + $yadrcchika_e;
			}		
			
			$dinanka = date('Y-m-d H:i:s');
			$tathya = mysqli_query($conn,"INSERT INTO `gellaluhogiondu_aidudi_phalitansa_funf` (`kalaparichaya`,`bele`,`phalitansa`,`phalitansadaprakara`,`dinankavannuracisi`) VALUES ('".$samasyesreni['atadaaidi']."','".$yadrcchika_final."','".$yadrcchika_sum."','uncensored','".$dinanka."')");
			
			$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 9, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
			WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
			AND INSTR(ojana, '".$yadrcchika_a."') > 0
			";
			$conn->query($nabikarana);
			$nabikarana = "UPDATE shonu_kaichila
			INNER JOIN (
				SELECT byabaharkarta, SUM(sesabida) AS total_paid
				FROM bajikattuttate_aidudi_funf
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
				AND INSTR(ojana, '".$yadrcchika_a."') > 0
				AND phalaphala ='gagner'
				GROUP BY byabaharkarta
			)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
			SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
			";
			$conn->query($nabikarana);
			if($yadrcchika_a <= 4){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_a, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '1'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 9, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
			WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
			AND INSTR(ojana, '".$yadrcchika_b."') > 0
			";
			$conn->query($nabikarana);
			$nabikarana = "UPDATE shonu_kaichila
			INNER JOIN (
				SELECT byabaharkarta, SUM(sesabida) AS total_paid
				FROM bajikattuttate_aidudi_funf
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
				AND INSTR(ojana, '".$yadrcchika_b."') > 0
				AND phalaphala ='gagner'
				GROUP BY byabaharkarta
			)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
			SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
			";
			$conn->query($nabikarana);
			if($yadrcchika_b <= 4){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_b, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '2'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 9, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
			WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
			AND INSTR(ojana, '".$yadrcchika_c."') > 0
			";
			$conn->query($nabikarana);
			$nabikarana = "UPDATE shonu_kaichila
			INNER JOIN (
				SELECT byabaharkarta, SUM(sesabida) AS total_paid
				FROM bajikattuttate_aidudi_funf
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
				AND INSTR(ojana, '".$yadrcchika_c."') > 0
				AND phalaphala ='gagner'
				GROUP BY byabaharkarta
			)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
			SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
			";
			$conn->query($nabikarana);
			if($yadrcchika_c <= 4){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_c, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '3'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 9, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
			WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
			AND INSTR(ojana, '".$yadrcchika_d."') > 0
			";
			$conn->query($nabikarana);
			$nabikarana = "UPDATE shonu_kaichila
			INNER JOIN (
				SELECT byabaharkarta, SUM(sesabida) AS total_paid
				FROM bajikattuttate_aidudi_funf
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
				AND INSTR(ojana, '".$yadrcchika_d."') > 0
				AND phalaphala ='gagner'
				GROUP BY byabaharkarta
			)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
			SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
			";
			$conn->query($nabikarana);
			if($yadrcchika_d <= 4){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_d, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '4'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 9, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
			WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
			AND INSTR(ojana, '".$yadrcchika_e."') > 0
			";
			$conn->query($nabikarana);
			$nabikarana = "UPDATE shonu_kaichila
			INNER JOIN (
				SELECT byabaharkarta, SUM(sesabida) AS total_paid
				FROM bajikattuttate_aidudi_funf
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
				AND INSTR(ojana, '".$yadrcchika_e."') > 0
				AND phalaphala ='gagner'
				GROUP BY byabaharkarta
			)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
			SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
			";
			$conn->query($nabikarana);
			if($yadrcchika_e <= 4){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_e, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '5'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			if($yadrcchika_sum <= 22){
				$weight = 'L';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$weight = 'H';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
				AND INSTR(ojana, '".$weight."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
					AND INSTR(ojana, '".$weight."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			if((fmod($yadrcchika_sum, 2)) == 0){
				$value = 'E';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			else{
				$value = 'O';
				$nabikarana = "UPDATE bajikattuttate_aidudi_funf set phalaphala = 'gagner', sesabida = ROUND(menge * wettanzahl * 1.98, 2), ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."'
				WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
				AND INSTR(ojana, '".$value."') > 0
				";
				$conn->query($nabikarana);
				$nabikarana = "UPDATE shonu_kaichila
				INNER JOIN (
					SELECT byabaharkarta, SUM(sesabida) AS total_paid
					FROM bajikattuttate_aidudi_funf
					WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."' AND prakar = '6'
					AND INSTR(ojana, '".$value."') > 0
					AND phalaphala ='gagner'
					GROUP BY byabaharkarta
				)  AS subquery ON shonu_kaichila.balakedara = subquery.byabaharkarta
				SET shonu_kaichila.motta = TRUNCATE(shonu_kaichila.motta + subquery.total_paid, 2)
				";
				$conn->query($nabikarana);
			}
			
			$nabikarana_dui = "UPDATE bajikattuttate_aidudi_funf set ergebnis = '".$yadrcchika_sum."', zufallig = '".$yadrcchika_final."', tiarikala = '".$dinanka."' WHERE kalaparichaya = '".$samasyesreni['atadaaidi']."'";
			$conn->query($nabikarana_dui);
		}
		else{
			$yadrcchika_a = rand(0, 9);
			$yadrcchika_b = rand(0, 9);
			$yadrcchika_c = rand(0, 9);
			$yadrcchika_d = rand(0, 9);
			$yadrcchika_e = rand(0, 9);
			$yadrcchika_final = $yadrcchika_a.$yadrcchika_b.$yadrcchika_c.$yadrcchika_d.$yadrcchika_e;
			$yadrcchika_sum = $yadrcchika_a + $yadrcchika_b + $yadrcchika_c + $yadrcchika_d + $yadrcchika_e;
			
			$dinanka = date('Y-m-d H:i:s');
			
			$tathya = mysqli_query($conn,"INSERT INTO `gellaluhogiondu_aidudi_phalitansa_funf` (`kalaparichaya`,`bele`,`phalitansa`,`phalitansadaprakara`,`dinankavannuracisi`) VALUES ('".$samasyesreni['atadaaidi']."','".$yadrcchika_final."','".$yadrcchika_sum."','shonu','".$dinanka."')");
		}
	}
?>