#!/usr/bin/perl -w

use strict;

my ($val1, $val2) = (1, 1);
my $iter = 0;
my $subj1 = 7;
my $subj2 = 7;
my ($pub1, $pub2) = @ARGV;

while (++$iter) {
	$val1 *= $subj1;
	$val2 *= $subj2;
	$val1 %= 20201227;
	$val2 %= 20201227;
	if ($val1 == $pub1) {
		print "$iter loops for subj1\n";
		$val1 = $pub2;
		for (2 .. $iter) {
			$val1 *= $pub2;
			$val1 %= 20201227;
		}
		print "key=$val1\n";
	}
	if ($val2 == $pub2) {
		print "$iter loops for subj2\n";
		$val2 = $pub1;
		for (2 .. $iter) {
			$val2 *= $pub1;
			$val2 %= 20201227;
		}
		print "key=$val2\n";
	}
}

